TIL: Docker Namespaces

Ever wondered how containers have their own processes, networks, and even file systems — completely separate from the host?

That magical isolation isn’t just some Docker black box, it’s built on a powerful Linux kernel feature called namespaces.

But first, don’t confuse Docker namespaces with Kubernetes namespaces, they are completely different.

  • Docker namespaces are about OS-level isolation (processes, network, users).
  • Kubernetes namespaces are about logical separation within a cluster (dev, staging, prod, etc.).

So what are Docker namespaces?

Namespaces are like putting a container in its own bubble for each system resource:

NamespaceIsolatesExample
pidProcessesContainer has its own PID tree
netNetwork stackIts own IP, interfaces, routes
mntFile system mountsContainer’s file system
utsHostname & domainDifferent container hostname
ipcShared memorySeparate communication channels
userUser/group IDsMap users differently

The Result?

Each container thinks it’s a mini-computer, but all containers are just segmented views of the host, using namespaces to isolate what they can see and touch.

So next time you run:

docker run -it ubuntu bash

Namespaces = the reason Docker containers are lightweight and fast.

Related Post