← Knowledge Base
DockerReference note1 min read · updated 2026-11-27

Docker networks and talking between containers

User-defined networks, resolving containers by service name, and keeping databases off the internet.

dockernetworkingcompose

On a user-defined network (and in Compose) containers reach each other by service name: a reverse proxy can use reverse_proxy app:8080. The default bridge does not resolve names.

docker network ls
docker network create web
docker network inspect web
docker run -d --network web --name api myorg/api

Do not publish ports you do not need: a database only needs to be on the internal network, with no ports: entry. Publishing 5432:5432 makes it reachable from outside (and Docker bypasses ufw rules). Prefer one network for the proxy and the apps it serves, and a separate internal one for databases.