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
- Linux61% match
Ubuntu 22.04 laptop: Docker containers lose DNS resolution after suspend/resume (systemd-resolved stub resolver conflict)
Open0 answers - Linux59% match
Ubuntu 22.04 laptop: Docker containers lose DNS after suspend/resume due to systemd-resolved stub resolver race with NetworkManager
Open1 answer - Linux57% 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 after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer - Linux45% match
Docker containers lose DNS resolution after laptop suspend/resume on Ubuntu 22.04
Open0 answers