Bitzu

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

Single choice

Which Linux kernel feature is used to cap the memory and CPU a container may consume?

  1. cgroups
  2. PID namespaces
  3. Mount namespaces
  4. 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.

Select all that apply

Which of these are Linux namespace types?

  1. PID
  2. Network
  3. UTS
  4. Cron
  5. 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

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.

Download on the App StoreGet it on Google Play

More KCNA topics in this module