Networking & Ports
Containers on the same bridge network each get a private IP and find one another by service name alone. That network isn't visible outside the host, though, so reaching a container from outside means mapping a host port to a container port with something like `-p 8080:80`. Names on the inside, port mapping on the outside — telling those two apart is the whole point.
01 Concept at a Glance
Interactive Step-by-StepThree containers are up on the same bridge network. Each gets its own private IP.
02 Understand It Simply
For EveryoneLike office extensions. Inside the building (the bridge network) you dial a name or an extension directly; from outside you have to go through the main number (the host port) and be routed in.
Docker creates a bridge network and hands each container a private IP.
On a user-defined network the embedded DNS resolves container names, so you connect to `db:5432` by name.
External traffic arrives through port mapping (NAT) from host port to container port, and any port you didn't map simply can't be reached.
Containers on different networks can't reach each other even by name.
- –Wiring up microservice communication
- –resolving port conflicts
- –minimising external exposure
- –and tuning isolation by splitting networks
03 Frequently Asked Questions
FAQWhat is Networking & Ports?+
Containers on the same bridge network each get a private IP and find one another by service name alone. That network isn't visible outside the host, though, so reaching a container from outside means mapping a host port to a container port with something like `-p 8080:80`. Names on the inside, port mapping on the outside — telling those two apart is the whole point.
Where is Networking & Ports used?+
Wiring up microservice communication, resolving port conflicts, minimising external exposure, and tuning isolation by splitting networks.
What's a simple analogy for Networking & Ports?+
Like office extensions. Inside the building (the bridge network) you dial a name or an extension directly; from outside you have to go through the main number (the host port) and be routed in.
