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

kane picture kane · Dec 15, 2015 · Viewed 19.9k times · Source

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.

Answer

Nat picture Nat · Dec 16, 2015

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": ""
        }
}