Docker containers lose DNS resolution after laptop resume on Ubuntu 22.04 due to systemd-resolved stub resolver change
Environment
Ubuntu 22.04 desktop (kernel 5.15), Docker Engine 20.10.17, containers use default bridge network and rely on host's /etc/resolv.conf provided by systemd-resolved (127.0.0.53). Laptop uses NetworkManager with two interfaces: Wi‑Fi and VPN tun0 (WireGuard).
Symptoms
After resuming from suspend, running containers cannot resolve DNS names (e.g., apt update inside container fails resolving registry-1.docker.io); host DNS resolution works. Restarting Docker daemon temporarily restores resolution for a short period; then after next suspend it fails again.
Observations
Inside container: resolv.conf contains 127.0.0.53. host's /etc/resolv.conf is a symlink to /run/systemd/resolve/stub-resolv.conf. systemd-resolved status shows 'DNS Servers:' correct values but systemd-resolved.log shows messages 'Watchdog: interface tun0 disappeared' and 'Registered new stub listener on 127.0.0.53:53' after resume. strace of containerized process shows connect to 127.0.0.53:53 returns ECONNREFUSED periodically. Restarting Docker recreates containers and their /etc/resolv.conf entries then resolution works until next suspend. Disabling and re-enabling network interface on host doesn't affect containers' resolv failure; restarting systemd-resolved fixes host+containers.
Already attempted
Restarted systemd-resolved (systemctl restart systemd-resolved) — fixed host and containers until next suspend. Restarted docker.service — temporary fix. Recreated containers with --network host — resolves DNS reliably. Replaced /etc/resolv.conf inside container to point at public DNS (8.8.8.8) — works but undesirable due to split-DNS for VPN.
Question
How can I make Docker containers continue to resolve host-provided DNS (systemd-resolved stub) reliably across suspend/resume without restarting daemon or the containers? Is there a safe, persistent configuration change to prevent the stub listener from becoming unusable for containers after resume?
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
- Linux38% match
Ubuntu 22.04 host suspend/resume breaks LXD container veth interfaces — containers lose external network
Open0 answers - Linux31% match
systemd-resolved ignores per-connection DNS split-horizon rules after NetworkManager upgrade on Ubuntu 22.04
Open0 answers - Linux27% match
Docker containers lose DNS after laptop resumes from sleep
Open1 answer - Linux25% match
Docker containers see config file permission change after editor 'atomic save' — bind-mounted file temporarily unreadable until container restart
Open0 answers - Servers24% match
After a kernel upgrade Docker containers get 'permission denied' writing to bind-mounted volumes (overlay2/overlayfs change)
Open0 answers