After previous issues with DNS resolution within Docker containers, they started to occur again while attempting to setup a Gitea Action to build a Ubiquiti Unifi container.
It seemed to occur when the container had the direct IP address of my DNS Server in /etc/resolv.conf rather than using the docker proxied DNS. When doing basic investigation (nslookup google.com
) within an impacted container, the error I received was:
;; reply from unexpected source: 172.18.0.1#53, expected 10.0.0.1#53
My DNS server is on 10.0.0.1. 172.18.0.1 is the Gateway on the Docker network in use by the container.
This error pointed me to this forum post and a simple fix in the Adguard Home docker compose file. Instead of:
ports:
- 53:53/udp
- 53:53/tcp
it needed to be changed to:
ports:
- 10.0.0.1:53:53/udp
- 10.0.0.1:53:53/tcp
to force docker to bind that port to the “external” IP of the machine rather than the docker network IP. After this the DNS resolution errors stopped.