Ubuntu – Docker DNS not working

dockerUbuntu

I'm on ubuntu 16:

I have a server running a docker container with Bind9 that works as my network DNS server at 192.168.3.70. All the hosts from my network use this as DNS and it works great.

I have another container on that host running Jenkins and DNS does not work.

Here is what I tried with my /etc/init.d/docker:

# modify these in /etc/default/$BASE (/etc/default/docker)
DOCKER=/usr/bin/$BASE
# This is the pid file managed by docker itself
DOCKER_PIDFILE=/var/run/$BASE.pid
# This is the pid file created/managed by start-stop-daemon
DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS="--dns 192.168.3.70 --dns 8.8.8.8"
DOCKER_DESC="Docker"

This does not work, Jenkins still has no DNS.

I have restarted the daemon, of course, and no change.

What's wrong?

EDIT

So, I ran docker exec -i -t d...... /bin/bash and got a bash shell.

cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.3.70
search olympus

This is a correct DNS server, and I can ping 192.168.3.70

jenkins@d76b1da9544d:/$ ping 192.168.3.70
PING 192.168.3.70 (192.168.3.70): 56 data bytes
64 bytes from 192.168.3.70: icmp_seq=0 ttl=64 time=0.094 ms
64 bytes from 192.168.3.70: icmp_seq=1 ttl=64 time=0.073 ms

Still no dns.

Best Answer

Docker is entirely abstracting the network, into a very complex intricated mess.

I believe that it's configured to redirect DNS connections from other computers, to the DNS container. While DNS connections from the box itself are not intercepted by Docker.

It is a common issue. Docker runs the services and you're left on your own to connect them together.

The right way to solve it would be to analyse in depth the network configuration and reconfigure it in a way that services can communicate. However, it's very complicated, we are probably both not qualified for that and stackoverflow is not appropriate to run a long debugging session.

Thus we'll have to live with a simple workaround:

Run your DNS servers normally on a regular server, don't dockerize them. DNS service is critical in an infrastructure. It's common to have have small servers/VMs just for that.