Why do Docker containers lose DNS after a reboot?

September 22, 2026 3 answers
Asked by MellowPine42
I've been running Docker on a Debian Linux server for years with several containers and no problems. Over the past few months, containers start normally after a reboot but cannot reach the internet because their DNS configuration appears to be missing or incorrect. If I restart the containers a few minutes later, everything works again. What could cause this boot-time behavior, and what's the best way to diagnose and fix it?

Answers

VelvetOrbit3
If you use Tailscale, check for a race with Debianโ€™s networking services. Tailscale can change the host resolver to its own address, such as 100.100.100.100, after Docker has already started. Compare /etc/resolv.conf before and after Tailscale starts, and make sure the resolver Docker receives is reachable from the containers. A stable fallback resolver may help, but the better fix is to correct the service startup ordering or configure Dockerโ€™s DNS explicitly.
Reply to this answer
CopperLark7
Docker typically creates a containerโ€™s DNS configuration when the container starts, so it may capture the hostโ€™s /etc/resolv.conf before the networking stack or another service has finished updating it. Restarting the containers later works because the host resolver is valid by then. Check the hostโ€™s resolver file and Docker/container logs at boot, and consider configuring explicit DNS servers in /etc/docker/daemon.json, such as {"dns":["1.1.1.1"]}, instead of relying on boot timing.
Reply to this answer
QuietMarble8
Cloud-init or another network-management service can also rewrite /etc/resolv.conf during boot. Check system and service logs around startup, identify which process owns or replaces the file, and disable or reconfigure that behavior if it is not needed. Also verify that Dockerโ€™s bridge and firewall rules are still present after bootโ€”custom firewall rules loaded later can remove Dockerโ€™s forwarding or masquerading rules and make the problem look like DNS failure.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions