Skip to content

Instantly share code, notes, and snippets.

@jesugmz
Last active August 18, 2018 04:07
Show Gist options
  • Save jesugmz/fc01dcb41fbbb894d946fb0f2396c427 to your computer and use it in GitHub Desktop.
Save jesugmz/fc01dcb41fbbb894d946fb0f2396c427 to your computer and use it in GitHub Desktop.
Resolve domains locally with docker engine DNS

Custom DNS docker engine level

Depend of the init system of the OS:

Systems using Upstart and SysVinit

  • Add in /etc/default/docker DOCKER_OPTS="--dns <DNS_IP_1> --dns <DNS_IP_2>"
  • $ sudo service docker restart

Systems using SystemD

  • Add in /etc/docker/daemon.json
{
	"dns": ["<DNS_IP_1>", "<DNS_IP_2>"]
}
  • $ sudo service docker restart

Custom DNS per container

Docker run

  • Add the parameters --dns=<DNS_IP_1> --dns=<DNS_IP_2>

Docker Compose

  • Add in the docker-compose.yml
dns:
  - <DNS_IP_1>
  - <DNS_IP_2>

If does not work add a network_mode.

More info:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment