Oh My Algorithm
Concept GuideBridge · Port Mapping

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-Step
Docker Networking · Bridge & Port Mapping
External client · browser
Host :8080opened with -p 8080:80
Host :3000 · :5432not mapped — unreachable from outside
Port mapping (NAT) · host port → container port
GET200GET
web172.17.0.2 : 80
api172.17.0.3 : 3000
db172.17.0.4 : 5432
User-defined bridge network · 172.17.0.0/16 · embedded DNS
api:3000db:5432api:3000db:5432
Containers on another network — not reachable, even by name

Three containers are up on the same bridge network. Each gets its own private IP.

Logic Node1 / 8

02 Understand It Simply

For Everyone
🔑Analogy

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.

💡In Plain Words

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.

📍Where It's Used
  • Wiring up microservice communication
  • resolving port conflicts
  • minimising external exposure
  • and tuning isolation by splitting networks

03 Frequently Asked Questions

FAQ
What 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.

Guide Progress0%