DNS config with docker
Published in
1 min readNov 18, 2016
Docker not shares the hosts nameservers and nameresolves(which exists on /etc/resolve.conf in host). To specify the external name servers and name resolves docker options can be used.
Add following configs to docker config file to setup external nameservers and nameresolves. Config files exists in /etc/default/docker on linux or /var/lib/bootdocker/profile OSX.
set name servers
DOCKER_OPTS=”--dns=10.13.20.15 --dns=8.8.8.8"
set search domain
DOCKER_OPTS=”--dns-search=pagero.local"
example docker config
Following is the example config file which exists on /etc/default/docker on linux
example resolve.conf
Following is the /etc/resolve.conf file of the docker container. To view this I have connected to running docker container via the command
docker exec -it <container id> bash
docker exec -it abf1b8c091f5 bash