Categories
How-To Random

Hardcode DNS server in docker

Perhaps not the best way to handle this but for a quick and dirty fix this might work for you.

Edit /etc/docker/daemon.json

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

Restart the docker daemon for those changes to take effect:

sudo systemctl restart docker

Now when you start a container, docker will populate /etc/resolv.conf with the values from daemon.json

Why did I do this?

I wanted my dockers to resolve differently than the hosts they are running from.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.