How do I configure which DNS server docker uses in Docker Desktop for Mac?

In current versions of Docker for Mac, you can go to the Whale Icon -> Preferences -> Daemon -> Advanced and adjust the daemon level DNS settings with a daemon.json config. If your config is currently empty, this would add your own DNS setting with two entries:

{
  "dns": ["8.8.8.8", "192.168.0.1"]
}

If you already have content in here, then add an entry for "dns" to your json. See the daemon configuration documentation for other options you can add here.


As a one liner:

sed -i '$s/}/,\n{"dns": ["8.8.8.8", "192.168.0.1"]}}/' ~/.docker/daemon.json

(For MacOS, the daemon configuration is in ~/.docker/daemon.json).