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:
docker run --dns=<ip-address>
DOCKER_OPTS="--dns ip-address"to the Docker daemon file
You can also specify the search domain using