O'Reilly logo

Learning Docker Networking by Santosh Kumar Konduri, Vaibhav Kohli, Rajdeep Dua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring a DNS server

Docker provides hostname and DNS configurations for each container without us having to build a custom image. It overlays the /etc folder inside the container with virtual files, in which it can write new information.

This can be seen by running the mount command inside the container. Containers receive the same resolv.conf file as that of the host machine when they are created initially. If a host's resolv.conf file is modified, this will be reflected in the container's /resolv.conf file only when the container is restarted.

In Docker, you can set DNS options in two ways:

  • Using docker run --dns=<ip-address>
  • Adding DOCKER_OPTS="--dns ip-address" to the Docker daemon file

You can also specify the search domain using --dns-search=<DOMAIN> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required