Docker is a software tool primarily used by programmers as it is the mechanism programmers use to produce container images.
My machine is on a private network with private DNS servers, and a private zone for DNS resolution. I can resolve hosts on this zone from my host machine, but I cannot resolve them from containers running on my host machine.
Host:
root@host:~# 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 127.0.1.1
root@host:~# ping privatedomain.io
PING privatedomain.io (192.168.0.101) 56(84) bytes of data.
Container:
root@container:~# 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 8.8.8.8
nameserver 8.8.4.4
root@container:~# ping privatedomain.io
ping: unknown host privatedomain.io
It's fairly obvious that Google's public DNS servers won't resolve my private DNS requests. I know I can force it with docker --dns 192.168.0.1
, or set DOCKER_OPTS="--dns 192.168.0.1"
in /etc/default/docker
, but my laptop frequently switches networks. It seems like there should be a systematic way of solving this problem.
/etc/docker/daemon.json
add"dns": ["x.y.z.a"]
--> ip fromnetstat -antu | grep :53
--> find for IP addresses that are not localhost (10.x
or192.x
or172.x
) – Devlen