Depend of the init system of the OS:
- Add in /etc/default/docker
DOCKER_OPTS="--dns <DNS_IP_1> --dns <DNS_IP_2>"
$ sudo service docker restart
- Add in /etc/docker/daemon.json
{
"dns": ["<DNS_IP_1>", "<DNS_IP_2>"]
}
$ sudo service docker restart
- Add the parameters
--dns=<DNS_IP_1> --dns=<DNS_IP_2>
- Add in the docker-compose.yml
dns:
- <DNS_IP_1>
- <DNS_IP_2>
If does not work add a network_mode.
More info: