How I can add new nameserver in /etc/resolv.conf
(dockerfile)?
On my dockerfile I use:
FROM ubuntu:14.04
RUN echo \"nameserver 10.111.122.1
The DNS configuration of a Docker container may be adjusted during the creation of the container and does not need to be hard-coded in the Docker image itself.
Passing a single DNS server to the container works by providing the --dns
parameter:
$ docker run --rm --dns=8.8.8.8
You're free to provide more than one DNS server and you can also define other DNS related options like the DNS search name or common DNS options:
$ docker run --rm --dns=8.8.8.8 --dns=8.8.4.4 --dns-search=your.search.domain --dns-opt=timeout:50
If you pass cat /etc/resolv.conf
as command to your container, you can easily verify that the passed DNS configuration options made it into the container's DNS configuration:
$ docker run --rm --dns=8.8.4.4 --dns=8.8.8.8 --dns-search=your.domain.name --dns-opt=timeout:50 alpine cat /etc/resolv.conf
search your.domain.name
nameserver 8.8.4.4
nameserver 8.8.8.8
options timeout:50
Please also refer to the docker run
configuration which can be found at https://docs.docker.com/engine/reference/commandline/run/