kane
kane

Reputation: 6017

How to change "default" docker-machine's dns settings

I know how to create a new docker-machine with dns settings

docker-machine create -d virtualbox --engine-opt dns=8.8.8.8 my_machine

But there is already a "default" virtualmachine so is there a way to change its dns?

I read online ways to do this with boot2docker, but that tool is deprecated and docker-machine has replaced it. Unfortunately, it's so new that I haven't found much online about this.

Upvotes: 29

Views: 43078

Answers (2)

Nat
Nat

Reputation: 3717

Go to ~/.docker/machine/machines/default/config.json and add your own DNS server into HostOptions/EngineOptions/Dns and restart docker machine.

{  
   "HostOptions": {
        "Driver": "",
        "Memory": 0,
        "Disk": 0,
        "EngineOptions": {
            "ArbitraryFlags": [],
            "Dns": ["192.168.99.1","8.8.8.8","8.8.4.4"], <-- set it here
            "GraphDir": ""
        }
}

Edit:

The Dns setting in config.json seems to be ignored in the new version of docker-machine. The only thing that seems to work is to add line (edit this to match your needs)

"${DOCKER_MACHINE}" ssh "${VM}" "sudo sed -i.bkp '/--label provider=virtualbox/a --dns 8.8.8.8\\\n--dns 8.8.4.4' /var/lib/boot2docker/profile && sudo /etc/init.d/docker restart"

after

yes | "${DOCKER_MACHINE}" regenerate-certs "${VM}"

in script start.sh, which is run every time Docker Quickstart Terminal is started.

Then shut down the machine (if it's running) and open a new instance of the Docker Quickstart Terminal.

Upvotes: 43

mukade
mukade

Reputation: 660

On Windows 10 docker's gui give some facilities.

Just right click on docker's icon in the tray bar and select "Settings" item.

Docker's options

Then, on the Docker's window, select the "Network" section and change the DNS option from "Automatic" to "Fixed" and hit "Apply". Docker will restart itself after that. I putted the Google's DNS (8.8.8.8) and it worked fine to me.

docker's network section with dns config

Hope it helps.

Upvotes: 5

Related Questions