Tech●●●●●Difficulty 5 of 5

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 story

Two 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.

Two jobs, two kernel features

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

  1. 1.What is the difference between namespaces and cgroups?
  2. 2.What does the host see when a container's first process is numbered 1?
  3. 3.What happened to the "process containers" project from Google?

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".

Sources (3)

No source, no claim. Every fact in this lesson (17 claims) cites at least one of these.

  1. [1]Linux namespaces · Wikipedia
  2. [2]Cgroups · Wikipedia
  3. [3]OS-level virtualization · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗