FULL AI ANALYSIS

Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04

Generated Oct 20, 2026, 9:41:02 AM

Analysis summary

Docker copies the host's /etc/resolv.conf at container creation; when that file points at the host's stub (127.0.0.53) the container cannot reach it because 127.0.0.53 is the loopback address inside the container, not the host. This misconfiguration is the most likely cause. Alternate approaches are to make containers use fixed external DNS servers via daemon.json, or change the host so systemd-resolved exposes the upstream servers in a file Docker can read (for example symlink /etc/resolv.conf to /run/systemd/resolve/resolv.conf) or disable the stub listener and allow DNS on the normal interfaces.

Possible causes

Docker copied host /etc/resolv.conf containing 127.0.0.53 (systemd stub) which is unreachable from inside containers

90%

systemd-resolved restarting changes /etc/resolv.conf and Docker doesn't update containers until recreating them

60%

NetworkManager or other network manager is toggling resolver configuration on interface reconfiguration

30%

Docker bug around live reload of daemon DNS settings (less common)

10%

Suggested fixes

1

Diagnostic step 1

Short-term: set explicit DNS in /etc/docker/daemon.json and restart Docker so containers use stable resolvers (example: { "dns": ["1.1.1.1","8.8.8.8"] }).

2

Diagnostic step 2

Preferred: disable systemd-resolved stub listener and point /etc/resolv.conf at /run/systemd/resolve/resolv.conf (edit /etc/systemd/resolved.conf, set DNSStubListener=no, restart resolved, then ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf).

3

Diagnostic step 3

Alternative: configure systemd-resolved to publish upstream servers to /etc/resolv.conf (via the symlink) so Docker copies actual upstream IPs.

4

Diagnostic step 4

Verify by creating a new container (docker run --rm alpine nslookup google.com) and by restarting systemd-resolved to confirm containers keep resolving.