DevOps · interactive
Container networking
Each container has its own network namespace, its own localhost and its own IP on a Docker network. Containers on the same user-defined network find each other by name; the host only sees ports you publish.
Your laptop (host)
docker network: app (172.18.0.0/16)
web
172.18.0.2
-p 8080:80
api
172.18.0.3
not published
db
172.18.0.4
not published
api → localhost:5432: connection refused
Inside a container, localhost is that container. There's no Postgres in api, so: connection refused.
Connection
Step 1 of 4 · read left to right
In production
Tools and technologies
Docker and Compose networking is where most local setups break.
Not tied to one language — use these names when you search docs or design a system.