What really keeps one container from seeing another?
To Linux, a container is a bundle of two kernel tricks: one controls what a process can see, the other how much it can use.
▶ Start the storyTwo Linux features do the work: namespaces decide what a process can see, and cgroups decide how much it can use. Put simply, cgroups dictate how much of a system's resources a process can use, such as CPU, memory and disk limits, while namespaces dictate what a process is allowed to see and interact with. Together they are the foundational technologies underpinning container platforms such as Docker, Kubernetes, LXC and Podman.
Namespaces
- Decide what a process can see
- , , user IDs, file names, network interfaces
cgroups
- Decide how much it can use
- CPU, memory and disk limits
- Can also measure usage, for billing
Namespaces partition the 's resources so that one set of processes sees one set of resources and another set sees different ones. The result is the illusion that a process is the sole user of the machine: it gets its own , hostname, user IDs, file names and network interfaces. The first process created in a new process-ID namespace is numbered 1. The host, though, sits in the initial namespace and can see every process in every container, just under different numbers.
cgroups, short for control groups, limit, account for and isolate the resource usage of a collection of processes. Groups can be set not to exceed a memory limit, an bandwidth limit or a CPU quota, and they can measure a group's usage, for example for billing. They began at Google: engineers started the work in 2006 under the name "process containers", then renamed it in late 2007 to avoid confusion over the word "container". It was merged into Linux in January 2008.
So a container is a clever arrangement of limited views and limited budgets. It is not a perfect wall: even , one of its ancestors, offers security that is not perfect.
Quiz me
0/3
Recap
Namespaces decide what a process sees; cgroups decide how much it gets.
💡 A trick to remember it · Namespaces are the walls and windows, cgroups the electricity meter: the first decides what you can see, the second how much you can use.
Surprising fact · Google engineers started cgroups in 2006 under the name "process containers".
Connects to
- ☸️ How does Kubernetes keep thousands of containers running?
- 🔺 Why can't a system spread across the world be both always consistent and always available?
- 📦 Why did shipping software in containers change how it runs?
- 👻 How could a processor's habit of guessing ahead leak your secrets?
- 🔓 Why did an NBA team hand over every employee's tax forms to a scammer?
Sources (3)
No source, no claim. Every fact in this lesson (17 claims) cites at least one of these.