network namespace
The namespace that gives a process its own network interfaces, addresses, routes and ports.
In more detail
Each container normally gets its own network namespace, so two containers can both listen on port 8000 without clashing. That is also why a service listening on localhost inside a container cannot be reached from the host: localhost there is the container own loopback interface. Port publishing forwards traffic from the host into this namespace.
Related terms
- namespace (Linux) — A Linux kernel feature that controls what a process can see, such as which other processes, network or host name.
- port publishing — Forwarding a port on the host to a port inside a container so the service can be reached from outside.
- localhost — The name a machine uses for itself; traffic sent there never leaves that machine.
- bridge network — The default Docker network type: a private network inside the host that containers join, with its own private addresses.
Taught in
- Sidecars And Init Containers — Certified Kubernetes Application Developer (CKAD) Exam Prep
- Namespaces And Cgroups: Isolation And Limits — Docker Architecture & Production Containers
- Run The Spine Service And Publish Its Port — Docker Architecture & Production Containers
- Bridge Networks, DNS And Container Communication — Docker Architecture & Production Containers
- Port Publishing, Localhost And Network Troubleshooting — Docker Architecture & Production Containers
- Health Checks, Dependencies And Reliable Startup — Docker Architecture & Production Containers