Docker Community Forums

Share and learn in the Docker community.

Docker containers can't resolve DNS request when DNS server is contained in another Docker container

Hi,

I’m running a DNS server in a container which is exposing port 53 to my local network. This works fine for all my network devices and even the linux host on which the container is ran. (This DNS container is the only option for DNS resolution, no backup DNS’s are allowed)

Some additional info:
My local network IP range is 192.168.1.x
The docker DNS container has its own network bridge 10.0.0.x, and it’s own IP address on that bridge is 10.0.0.2 (10.0.0.1 being the gateway).

However when I run other containers they have issues resolving DNS queries when going over the docher host. The query arrives correctly in the DNS container but as seen in the DNS container the query is coming from the 10.0.0.1 gateway IP-address.
I’m assuming this query response doesn’t get routed correctly back to the source container.

One solution is adding all containers to the DNS network bridge 10.0.0.x and setting the 10.0.0.2 IP-address as DNS server for these containers.

I’d rather have another solution which doesn’t require to add every container to the DNS bridge, but instead route all requests via the docker host.

Kind regards,
Frederic Depuydt