Interview Prep/Networking/DNS resolution failures

`curl: (6) Could not resolve host: api.example.com` inside a container but it resolves on the host.

BeginnerTroubleshootingDNS resolution failures
Answer

Likely causes → The container's /etc/resolv.conf points at 127.0.0.53 (systemd-resolved stub) copied from the host, which isn't reachable inside the container namespace; or a custom network's embedded DNS (127.0.0.11) can't reach upstream.

Diagnose →

docker exec app cat /etc/resolv.conf
docker exec app getent hosts api.example.com
resolvectl status

Fix → Set daemon DNS in /etc/docker/daemon.json ("dns": ["10.0.0.2"]) or per-container --dns. Docker normally rewrites a loopback resolver to defaults; corporate DNS needs to be explicit.

Prevent → Pin resolver configuration for the runtime rather than inheriting host defaults.

All Networking questions Roadmap: Networking for DevOps

More on DNS resolution failures