Interview Prep/Docker/Networking, DNS and Compose

Container-to-container requests fail intermittently by name after a container restarts.

AdvancedTroubleshootingNetworking, DNS and Compose
Answer

Likely causes → Client (nginx, JVM) cached the old IP; DNS TTL and resolver caches ignore the new address.

Diagnose → docker exec web getent hosts api vs the IP in nginx upstream; docker network inspect.

Fix → In nginx use resolver 127.0.0.11 valid=10s; with variable in proxy_pass; JVM networkaddress.cache.ttl=10; or reload nginx.

Prevent → Configure resolver behaviour when using dynamic backends.

All Docker questions Roadmap: Docker & containers

More on Networking, DNS and Compose