Interview Prep/Docker/Networking, DNS and Compose

Containers cannot reach the internet: `Temporary failure in name resolution`

AdvancedTroubleshootingNetworking, DNS and Compose
Answer

Likely causes → DNS config (host uses 127.0.0.53 stub), IP forwarding off, firewall blocking forward, or VPN conflict.

Diagnose →

docker run --rm busybox nslookup google.com
docker run --rm busybox ping -c1 1.1.1.1
sysctl net.ipv4.ip_forward
iptables -t nat -L POSTROUTING -n | grep MASQ

Fix → Set "dns": ["1.1.1.1"] or corp DNS in daemon.json; enable net.ipv4.ip_forward=1; restart docker.

Prevent → Standardize host DNS and forwarding sysctls.

All Docker questions Roadmap: Docker & containers

More on Networking, DNS and Compose