Skip to main content
In this lesson we explore how Docker uses Linux namespaces to isolate containers from the host. Namespaces are a kernel feature that partition kernel resources so processes inside a container have the illusion of running on their own system, even though they share the same host kernel. Namespaces Docker commonly relies on:
  • Process IDs (PID)
  • Network (interfaces, routing, firewall)
  • Inter-process communication (IPC — shared memory, semaphores)
  • Mounts (filesystem namespace)
  • UTS (hostname / domainname)
  • User (user/group IDs)
An infographic titled "Linux Namespaces" showing six colored cards for PID, Network, IPC, Mount, UTS, and User namespaces. Each card gives a short description (e.g., process IDs; interfaces/routing/firewall; shared memory/semaphores; filesystem mounts; hostname/domain; user/group IDs).
Focus: PID namespaces When the Linux kernel boots it creates the initial process with PID 1 (the “init” process). Every process on the machine is assigned a unique PID in the global (host) PID namespace. Containers, however, need their own process numbering so services appear to start at PID 1 inside the container. PID namespaces provide that illusion. The kernel maintains mappings so a process has one PID inside a PID namespace and a different, unique PID in the host’s global namespace. That mapping means a process inside a container can be PID 1 (and behave like an init for that container) while the host assigns that same kernel process a different global PID. How PID namespaces look conceptually:
A diagram showing PID namespaces: the left side lists host Linux process IDs (PID: 1–6) and the right side shows a child/container PID namespace with its own processes labeled PID: 1 and PID: 2. The graphic illustrates that the container has a separate PID numbering isolated from the host.
Practical examples Inside a container you commonly see services starting at PID 1. Example output from ps inside a container running NGINX:
The ps output above is relative to the container’s PID namespace. On the Docker host the same kernel processes exist but with different global PIDs:
This demonstrates:
  • The kernel is managing one set of processes, but PID namespaces provide different PID views.
  • Inside the container the NGINX master appears as PID 1; on the host it’s a higher-numbered PID.
  • Tools like /proc are namespaced too — the container sees a /proc that reflects its PID namespace.
Quick checks you can run
  • From the host: docker top <container-id> to see the host PIDs of container processes.
  • From inside the container: ps or cat /proc/1/status to confirm PID 1 is the container’s main process.
  • To run without PID isolation (share host PID namespace): docker run --pid=host ... (not recommended for untrusted workloads).
PID namespaces provide a separate view of process IDs. The kernel still enforces unique global PIDs, but it maps namespace-local PIDs to the corresponding global PIDs so that processes inside a container can appear to start at PID 1.
Further reading and references

Watch Video