KCNA ยท Containers and images
Namespaces and cgroups
Linux namespaces for isolation and cgroups for resource limits as the building blocks of containers.
Key points
- A container is built from two Linux kernel features.
- Namespaces control what a process can SEE: its own process IDs (PID), network stack, mounts, hostname (UTS), users, IPC objects and more.
- Control groups (cgroups) control what a process can USE: they cap and account for CPU, memory and I/O. Isolation comes from namespaces, resource limits from cgroups.
Source: https://man7.org/linux/man-pages/man7/namespaces.7.html
Practice questions
Which Linux kernel feature is used to cap the memory and CPU a container may consume?
- cgroups
- PID namespaces
- Mount namespaces
- User namespaces
Show answer
Answer: A. cgroups
Control groups (cgroups) enforce and account for resource usage. Namespaces only change what a process can see, not how much it can use.
Which of these are Linux namespace types?
- PID
- Network
- UTS
- Cron
- Scheduler
Show answer
Answer: A. PID, B. Network, C. UTS
PID, network and UTS (hostname) are real namespace types. Cron and scheduler are not namespaces.
True or false: Linux namespaces are what limit how much CPU a container can use.
Show answer
Answer: False
False. Namespaces isolate what a process can see; CPU and memory limits are enforced by cgroups.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
