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:
- Creates namespaces (pid, mnt, net, uts, ipc, optionally user, cgroup).
- Puts the process in a cgroup with the configured limits.
- Pivots root (
pivot_root) into the image's root filesystem (an overlayfs mount). - Drops capabilities, applies a seccomp syscall filter and an AppArmor/SELinux profile.
- Executes the entrypoint as PID 1.
Nothing more: a container is a regular Linux process with these settings applied.
More on Kernel Parameters, Namespaces & cgroups
What is sysctl and how do you make a change persistent?BeginnerWhy does Kubernetes require `net.ipv4.ip_forward=1` and `br_netfilter`?AdvancedAre sysctl settings global, or per namespace?AdvancedWhat are Linux namespaces? List all types.BeginnerHow do you create and enter namespaces by hand?AdvancedHow does a network namespace get connectivity?Advanced