DNS Server in Docker Container

I have the DNS server Unbound in a docker container. This container has the following port mapping in the docker deamon:>53/tcp,>53/udp

The docker host has the IP address and a local DHCP server announces the host’s IP as the local DNS server. This works fine all over my local network.
The host itself uses this DNS server through the IP That’s the address that is put to the host’s /etc/resolv.conf. (I know it would not work with docker if there was as the nameserver address.)

  • permission error on executing docker run
  • multiple SLF4J bindings on maven run in docker
  • Trouble deploying docker on AWS with ecs-cli
  • Updating Short and Full Descriptions on Docker Hub
  • Run multiple containers on same docker network localhost
  • How to specify an iterator in the volume path when using docker-compose to scale up service?
  • I have some other docker containers and they are supposed to use this DNS server as well. The point is, they don’t.

    What actually happens is this:
    Whithin a random container I can ping the host’s address as well as the address of the unbound-container. But when I use dig inside a container I get these results:

    # dig @ ...
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 22778
    ;; flags: qr rd ad; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
    ;; WARNING: recursion requested but not available

    # dig @ ...
    ;; reply from unexpected source:, expected

    This looks like some internal DNS server intercepts the queries and tries to answer them. That would be fine if it would use the host’s DNS server to get an answer, but it doesn’t. DNS doesn’t work at all in the containers.

    Am I doing wrong or is docker doing something it should not ?

  • In virtual-machine Docker push to private registry failed under proxy
  • Transitioning from other local development tools to Docker
  • how to import large file in a local cartodb running in a docker container
  • ansible - define var's value depending on another variable
  • Is it necessary to use Docker in Java?
  • how to make ebs volume usable by docker stack
  • One Solution collect form web for “DNS Server in Docker Container”

    The issue is iptables UDP nat for DNS server. You’re querying the host IP while it’s the docker bridge network’s response.

    To fix this issue in at least to ways:

    • Use container IP (DNS container) as DNS resolver if possible.


    • Provide --net=host to your DNS server container and remove port mapping altogether. Then host IP DNS would work as expected.
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.