The Default Bridge Trap

Why http://api/ Can't Be Found

Scenario: Your nginx proxy forwards to http://api/. Both containers are running. nginx crash-loops with host not found in upstream "api". The code is fine, the containers are fine - the network is the bug.

Docker's default bridge connects containers, but provides no name resolution - containers only reach each other by IP. Container-name DNS is a feature of user-defined networks:

$ docker network create shopnet          # user-defined bridge
$ docker run -d --name api --network shopnet my-api
$ docker run -d --name web --network shopnet -p 8080:80 my-proxy
# now, inside web:  http://api/  resolves ✓
default bridgeuser-defined bridge
Name → IP resolution✅ built-in DNS
Isolationall containers togetheronly members see each other
Connect/disconnect livelimiteddocker network connect/disconnect
Tip: Rule of thumb: never deploy multi-container apps on the default bridge. One docker network create fixes discovery and gives you isolation between app stacks for free. (Compose does this automatically.)
$ docker network ls
$ docker network inspect shopnet     # members, subnet, IPs