The Default Bridge Trap
Why http://api/ Can't Be Found
Scenario: Your nginx proxy forwards tohttp://api/. Both containers are running. nginx crash-loops withhost 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 bridge | user-defined bridge | |
|---|---|---|
| Name → IP resolution | ❌ | ✅ built-in DNS |
| Isolation | all containers together | only members see each other |
| Connect/disconnect live | limited | docker 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