Docker Community Forums

Share and learn in the Docker community.

DOCKER DNS change /etc/resolv.conf file


(Saffik) #1

I am using a docker-compose command to create and start my containers.

My Docker Version

docker --version
Docker version 17.09.0-ce, build afdb6d4

My Docker-Compose version

docker-compose --version
docker-compose version 1.16.1, build 6d1ac21

The .yml file that I’m using looks something like this: (Note that I’ve just shortened it to take sensitive things out)

    image: "zookeeper"
    - "NET_ADMIN"
    - "NET_ADMIN"
      SERVER_ID: 0
      NETEM_HOSTS: ""
      LOSS_VALUES: ""
      DELAY_VALUES: ""
    image: ""
    image: ""
version: "3.3"

Then I start using:

docker-compose --file compose.yml up -d

My Question is this:

  1. 1} After containers come up… when I go into a container, for e.g. in this case server-0, I don’t see the /etc/resolv.conf file updated to use these nameservers. Instead it uses the embedded dns of docker which is

  2. 2} How do I make sure that it uses what I specify in file that is used by docker-compose

  3. 3} I tried to do this with the command and it seems to work, but I need to do from compose-file
    docker run -p 4000:53 --dns=

  4. 4} Ideally, I want it to have the IP address of the container ‘fakedns’ so that it uses this one instead of the embedded one @

(Stuart Johnson) #2

From my own experiments, your --dns gets added to dockers internal dns server

However I agree this is confusing, and I think resolv.conf should have a comment included to say that it has been included. I created a pull request for this

What would also be useful, is if you could inspect the dns server from the docker command line.