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.
More on Networking, DNS and Compose
`curl: (7) Failed to connect to localhost port 8080: Connection refused` after `docker run -p 8080:80 nginx`.Beginner`Bind for 0.0.0.0:5432 failed: port is already allocated`Beginner`ping` works to IPs but DNS names fail on the default bridge: `ping: bad address 'db'`Beginner`getaddrinfo ENOTFOUND db` in a Compose app.BeginnerCompose: `service "api" depends on undefined service "db"`BeginnerCompose: `yaml: line 14: mapping values are not allowed in this context`Beginner