Docker containers lose DNS resolution after laptop suspend/resume on Ubuntu 22.04
Environment
Ubuntu 22.04 LTS desktop, kernel 5.15.0-56-generic, Docker Engine 20.10.12 from Docker CE repo, NetworkManager 1.36, systemd-resolved as stub resolver (127.0.0.53), containers started via docker-compose v1.29.
Symptoms
Containers that previously resolved external hostnames stop resolving DNS after laptop resumes from suspend. Domain lookups inside containers return 'temporary failure in name resolution' while host DNS (host nslookup) works normally.
Observations
After resume NetworkManager restarts and /etc/resolv.conf is rewritten to the systemd stub. Existing running containers keep the pre-resume /etc/resolv.conf contents copied at creation time. Restarting docker.service or restarting containers restores resolution. New containers created after resume have correct resolv.conf.
Already attempted
Restarted NetworkManager (no change while containers running), recreated an affected container (works), rebooted host (works but inconvenient), added explicit DNS in docker-compose (temporary fix), attempted to bind-mount host /run/systemd/resolve/resolv.conf into container (breaks other services).
Question
Why do containers lose DNS after resume and how can I make DNS stable across suspend/resume without restarting every container? Prefer minimally disruptive solutions for multi-container dev stacks.
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Linux57% match
Ubuntu 22.04 laptop: Docker containers lose DNS resolution after suspend/resume (systemd-resolved stub resolver conflict)
Open0 answers - Virtualization55% match
Docker containers lose DNS resolution after laptop resume on Ubuntu 22.04 due to systemd-resolved stub resolver change
Open0 answers - Linux55% match
Ubuntu 22.04 laptop: Docker containers lose DNS after suspend/resume due to systemd-resolved stub resolver race with NetworkManager
Open1 answer - Linux42% match
Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes
Solved1 answer - Linux41% match
Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer