Set custom DNS for Docker to use

Set custom DNS for Docker to use


Ahsan Nabi Dar

2 years ago | 1 min read

Did you know Docker internally uses Google DNS (, to resolve all domains when downloading images or installing dependencies while building images ?

Recently while building Smart Display with Phoenix LiveView I found that's the case when suddenly all new image downloads or build dependencies that were not cached started failing. As I run my own Ad blocking VPN with DoH and have a sink setup on my router for Google DNS as many of the devices for e.g Chromecast come hard coded with Google DNS to allow serving ads and geo lock your content.

Initially I couldn't figure out what could be the cause as this was something unexpected that docker by default is using Google DNS if nothing is configured.

First I had to update in /etc/default/docker for docker to be able to download dependencies

# Use DOCKER_OPTS to modify the daemon startup options.DOCKER_OPTS="--dns --dns"

but I hit a wall when the images that were not available locally started to fail as well up on further digging through found online that DNS config should also be updated in /etc/docker/daemon.json

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

For now this has resolved my Docker DNS issues and all images and dependencies are working well.


Created by

Ahsan Nabi Dar

"Technology is nothing. What’s important is that you have a faith in people, that they’re basically good and smart, and if you give them tools, they’ll do wonderful things with them." – Steve Jobs







Related Articles