What actually makes a container? Explain the mechanical difference between Linux Namespaces and Control Groups (cgroups v2).
“There is no such physical thing as a container in the Linux kernel—a container is simply a standard Linux process wrapped in Namespaces and Control Groups. Namespaces control visibility: they determine WHAT a process can see (isolating process IDs, network interfaces, mount points, and user IDs). Control Groups control resource allocation: they determine HOW MUCH compute the process can consume (enforcing hard limits on CPU bandwidth, memory footprint, swap, and disk I/O throughput).”
The 7 Core Linux Namespaces
| Namespace | Kernel Flag | What It Isolates |
|---|---|---|
| pid | CLONE_NEWPID |
Process ID space (container sees itself as PID 1). |
| net | CLONE_NEWNET |
Network devices, IP routing tables, port bindings, and iptables. |
| mnt | CLONE_NEWNS |
Filesystem mount points and root directory pivots (pivot_root). |
| user | CLONE_NEWUSER |
UID/GID mappings (root inside container maps to non-root UID on host). |
| ipc | CLONE_NEWIPC |
System V IPC and POSIX message queues. |
| uts | CLONE_NEWUTS |
Hostname and NIS domain name. |
| cgroup | CLONE_NEWCGROUP |
Cgroup root directory hierarchy view. |
S Situation
A multi-tenant host suffered performance degradation because a memory-intensive data processing container exhausted host memory, causing the kernel to kill an unrelated database.
T Task
Enforce strict resource boundaries and prevent noisy-neighbor container CPU and memory exhaustion.
A Action
Migrated our hosts to Linux cgroups v2 (`systemd.unified_cgroup_hierarchy=1`). Configured explicit memory limits (`memory.max` and `memory.high`) and CPU quotas (`cpu.max`) in our container runtimes, ensuring the OOM killer was confined strictly to the offending cgroup slice.
R Result
Completely prevented noisy-neighbor host crashes. Rogue container workloads were isolated and safely terminated by their local cgroup without impacting host stability.