Editing /etc/resolv.conf in a running container does not stick — Docker overwrites it on start and on networking changes. Configure the resolver at one of three levels:
Per container:
| |
Per Compose service:
| |
Daemon-wide, in /etc/docker/daemon.json, then sudo systemctl restart docker:
| |
--dns on the container overrides the daemon setting.
Bind-mounting your own file over the path is the fourth option, and worst:
| |
It survives restarts but stops Docker managing the file, breaking anything depending on Docker’s own name resolution inside the container.
Usual case: a container that must query a LAN resolver — AdGuard Home or Pi-hole — where the daemon-wide setting is wrong, since it sends every container there. See DNS troubleshooting for a container timing out against an internal upstream.