FULL AI ANALYSIS

Ubuntu 22.04: Docker containers intermittently lose DNS after host switches to systemd-resolved stub resolver during network changes

Generated Oct 29, 2026, 9:46:59 AM

Analysis summary

Docker embeds a DNS proxy for containers that forwards to the host resolver configured when the container starts. systemd-resolved's stub resolver (127.0.0.53) is local to host network namespace and can change behavior or socket availability on network transitions (VPN connect/disconnect). Existing containers retain the stale DNS forwarding config and cannot reach the host stub after it moves, causing resolution failures. Workarounds include configuring Docker to forward to systemd-resolved's actual upstream files, using network namespaces, or ensuring a stable host-forwarder reachable by container networks.

Possible causes

systemd-resolved stub listener bound to a host namespace or socket that becomes unreachable from container network namespace after host network changes.

90%

Docker's embedded DNS proxy caches and continues forwarding to a resolver instance that was replaced on network change.

75%

VPN client replaces /run/systemd/resolve/resolv.conf and changes split-DNS records, causing mismatch between container DNS and host resolver view.

60%

Firewall or netfilter rules isolate container bridge from host resolver socket after network reconfiguration.

30%

Suggested fixes

1

Diagnostic step 1

Configure Docker daemon to use systemd-resolved's upstream servers file instead of the stub: point Docker's dns to the IPs in /run/systemd/resolve/resolv.conf or set 'dns' in daemon.json to the internal resolver IP reachable from containers.

2

Diagnostic step 2

Alternatively, disable systemd-resolved stub and use the real resolver file (symlink /etc/resolv.conf to /run/systemd/resolve/resolv.conf) if split-DNS is not required, then restart docker.

3

Diagnostic step 3

As a more robust approach, run a small DNS forwarder on a stable host IP (127.0.0.1 or 127.0.0.2) reachable from containers and configure systemd-resolved to forward to it, or configure Docker to always use that forwarder.

4

Diagnostic step 4

Test changes on a single host: update /etc/docker/daemon.json with 'dns': ["<stable-resolver-ip>"] and restart docker, then verify existing long-lived containers continue resolving after network changes.

5

Diagnostic step 5

If using VPN split-DNS, examine VPN client hooks to update a stable resolver and avoid replacing the stub listener on network transitions.