Interview Prep/Docker/Networking, DNS and Compose

Slow DNS: every outbound call in the container takes 5 seconds.

AdvancedTroubleshootingNetworking, DNS and Compose
Answer

Likely causes → AAAA lookups failing or timing out (no IPv6), conntrack race on UDP DNS, unreachable first resolver, ndots:5 search-list expansion.

Diagnose →

docker exec c cat /etc/resolv.conf
docker exec c sh -c 'time getent hosts example.com'
tcpdump -ni any port 53

Fix → Remove dead resolvers, use options single-request-reopen, set --dns-opt ndots:1, use fully qualified names with trailing dot, disable IPv6 where unused.

Prevent → Run a local caching resolver.

All Docker questions Roadmap: Docker & containers

More on Networking, DNS and Compose