NovFora Dev

Docker Compose networking issue: containers can't resolve each other by service name

Ethan Hughes

Ethan Hughes

2 months ago

I have a multi-container Docker Compose setup where services are on the same network but cannot resolve each other via container names — they only work using localhost which is incorrect for inter-container communication. I've verified that both services use the default bridge network created by Compose, and their DNS entries show up correctly with docker exec -it <container_id> ping <service_name>. The issue manifests when my web app tries to connect to the db service via db:5432 — it resolves but times out. I've tried rebuilding without cache, restarting both services, and even manually creating a bridge network with Docker CLI which didn't help. Could this be an MTU mismatch between Docker's virtual interface and my host network? Or perhaps some iptables rule is dropping traffic between containers on the same bridge?

Join the conversation to leave a reply.

Sign in to reply

Related topics