Skip to content
BENIBIX Learn

Container Network

Infrastructure📦 ContainersContainer Storage and Networking

Also known as Docker Network, Bridge Network (Docker), User-Defined Network, docker network create

A private network that lets boxes talk to each other by name.

Think of it like

Think of it like a private hallway. The rooms on it can knock on each other's doors by name.

Example

Lucy creates a network called shop and starts a web container and a db container on it. The web app connects to the database at the address db.

Why it matters

Apps split across containers need to find each other. Names on a shared network do that without fixed addresses.

Definition

A container network is a private network that containers join so they can talk. Each one gets its own address on it. On a network you make yourself, they can reach each other by name, such as db or web. The built-in default network, called bridge, does not look up names. Boxes on different networks cannot reach each other unless you join them.

Example code

bash
docker network create shop
docker run -d --network shop --name db -e POSTGRES_PASSWORD=pw postgres:17
docker run -d --network shop --name web -p 8080:80 shop-web
Both boxes join the shop network. So the web app can reach the database by the name db.
Web and db share the shop network, so web reaches the database by its name, db.

Common mistake

Expecting names to work on the default network. Only a network you create looks up container names.

Key takeaways

  1. 1
    Private. Only containers that join can talk.
  2. 2
    Names work. On a network you create yourself.
  3. 3
    Default is plain. The built-in bridge has no names.