Anthony Richir
Anthony Richir

Reputation: 649

Setting the DNS of all containers in a docker-compose

Is it possible to set the same DNS to all container in a docker-compose file at once instead of having to put it explicitly on each container ?

Upvotes: 0

Views: 1990

Answers (2)

Anthony Richir
Anthony Richir

Reputation: 649

The solution I've found is to edit DOCKER_OPTS in file /etc/default/docker with DOCKER_OPTS="--dns x.x.x.x --dns y.y.y.y" And then in /lib/systemd/system/docker.service, make sure that there is an EnvironmentFile defined and that the DOCKER_OPTS are used in ExecStart

ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS
EnvironmentFile=-/etc/default/docker

Upvotes: 1

Rawkode
Rawkode

Reputation: 22592

The only way would be to change the daemon configuration:

# /etc/docker/daemon.json
{ "dns": ["8.8.8.8", "8.8.4.4"] }

Upvotes: 0

Related Questions