Interview Prep/Linux/Kernel Parameters, Namespaces & cgroups

How are containers built from namespaces, cgroups and other kernel features?

AdvancedConceptKernel Parameters, Namespaces & cgroups
Answer

A container runtime (runc, crun) takes an OCI bundle and:

  1. Creates namespaces (pid, mnt, net, uts, ipc, optionally user, cgroup).
  2. Puts the process in a cgroup with the configured limits.
  3. Pivots root (pivot_root) into the image's root filesystem (an overlayfs mount).
  4. Drops capabilities, applies a seccomp syscall filter and an AppArmor/SELinux profile.
  5. Executes the entrypoint as PID 1.

Nothing more: a container is a regular Linux process with these settings applied.

All Linux questions Roadmap: Linux

More on Kernel Parameters, Namespaces & cgroups