FULL AI ANALYSIS

Docker containers lose DNS resolution after laptop suspend/resume on Ubuntu 22.04

Generated Oct 24, 2026, 9:21:01 AM

Analysis summary

Docker copies /etc/resolv.conf from the host into container filesystem at container start and does not update it when the host's resolver changes. On Ubuntu 22.04 systemd-resolved manages DNS via a local stub at 127.0.0.53 and NetworkManager rewrites /etc/resolv.conf on resume, so running containers keep stale resolver entries. Workarounds include: give containers a stable resolver (configure docker daemon dns entries), restart affected containers on resume, or change host resolver configuration so /etc/resolv.conf points to a stable upstream address.

Possible causes

Docker copies /etc/resolv.conf into containers at creation; host rewrite on resume leaves running containers with stale DNS

95%

systemd-resolved stub listener and Container loopback mismatch (127.0.0.53 inside host is not reachable from container loopback)

70%

NetworkManager triggers a resolv.conf change that introduces transient invalid nameserver entries until DNS service fully restarts

40%

Docker daemon bug where it doesn't watch for host resolver changes and update containers' resolv.conf

30%

Suggested fixes

1

Diagnostic step 1

Confirm issue: run cat /etc/resolv.conf on host and inside an affected container; compare nameserver lines pre/post-resume.

2

Diagnostic step 2

Quick fix: restart only affected containers: docker-compose restart <service> or docker restart <container>. Verify DNS works with dig or ping inside container.

3

Diagnostic step 3

Daemon-level fix: set a stable upstream in /etc/docker/daemon.json (e.g. {"dns": ["1.1.1.1", "8.8.8.8"]}) and restart docker.service. This forces containers to use those DNS servers regardless of host resolv.conf.

4

Diagnostic step 4

Alternative: configure systemd-resolved to expose real upstream (disable stub listener DNSStubListener=no) and symlink /etc/resolv.conf to /run/systemd/resolve/resolv.conf so resolv.conf contains upstream IPs reachable from containers.

5

Diagnostic step 5

Automation: add a systemd user/service script to restart docker containers on NetworkManager resume (use nm-online or systemd sleep hooks) to avoid manual restarts.