Ubuntu 22.04 laptop: Docker containers lose DNS resolution after suspend/resume (systemd-resolved stub resolver conflict)
Environment
Ubuntu 22.04 Desktop on a Lenovo X1 Carbon; Docker Engine 24.x using default bridge network; host uses systemd-resolved with DNS stub listener on 127.0.0.53 and NetworkManager manages network changes (Wi‑Fi to VPN).
Symptoms
After resuming from suspend, running containers cannot resolve DNS names (e.g., apt update inside container returns 'Temporary failure in name resolution'), while host DNS works. Restarting Docker daemon or recreating containers fixes DNS until the next suspend/resume.
Observations
On host: 'systemd-resolve --status' shows DNS servers changed after resume (VPN activated) and /etc/resolv.conf points to 127.0.0.53. Containers' /etc/resolv.conf files still list the previous DNS IPs or a stale stub address and do not update automatically. 'docker inspect' for container shows 'DNS' field empty (Docker copies host resolv.conf at container start). After resume, NetworkManager updates host stub resolver but Docker's embedded DNS inside container did not get refreshed. No DNS packets seen from containers to the new upstream server (tcpdump on docker0 shows no traffic).
Already attempted
Restarting Docker service restores container DNS (Docker rebuilds /etc/resolv.conf). Attempted to run containers with 'network=host' as a test — host name resolution worked inside host-networked containers after resume. Tried setting 'dns: 1.1.1.1' in docker-compose as a workaround — that avoids the issue but is not ideal for privacy/VPN contexts.
Question
Why do containers retain stale DNS after host network changes on resume, and how can I make Docker pick up updated systemd-resolved DNS without restarting containers or the Docker daemon each time?
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
- Linux60% match
Ubuntu 22.04 laptop: Docker containers lose DNS after suspend/resume due to systemd-resolved stub resolver race with NetworkManager
Open1 answer - Virtualization55% match
Docker containers lose DNS resolution after laptop resume on Ubuntu 22.04 due to systemd-resolved stub resolver change
Open0 answers - Linux54% match
Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes
Solved1 answer - Linux47% match
Docker containers lose DNS resolution after laptop suspend/resume on Ubuntu 22.04
Open0 answers - Linux42% match
Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer