liveBook · Manning

Cgroup

As explained in Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

A Linux kernel mechanism for grouping processes and limiting or accounting for their resource usage.

A cgroup is a Linux kernel mechanism that organizes processes into hierarchical groups whose resource usage can be limited and monitored. Containers use cgroups to stop one process group from dominating the system and preventing other workloads from making progress. section 1.2

Cgroups can constrain or account for resources such as:

Cgroups provide resource isolation rather than the complete container security boundary. Containers also rely on capabilities, SELinux, read-only kernel filesystems, seccomp, and user namespaces to restrict privilege and access. section 1.2

Podman services under systemd

Systemd places every process belonging to a service unit into the same cgroup hierarchy and uses the PID cgroup to track and manage the service. Podman’s process model lets systemd manage a containerized service’s processes, cgroups, and lifespan. section 7.0 section 1.3.7

Table 1.1 Advanced Linux security features (view table figure)

Component

Description

Reference

Linux capabilities

Linux capabilities subdivide the power of root into distinct capabilities.

The capabilities man page is a good overview of the available capabilities (https://bit.ly/3A3Ppeg).

SELinux

Security-Enhanced Linux (SELinux) is a Linux kernel mechanism that labels every process and every filesystem object on the system. A SELinux policy defines the rules on how labeled processes interact with label objects. The Linux kernel enforces the rules.

I wrote the SELinux Coloring Book, which is a fun way to help you understand SELinux (https://bit.ly/33plEbD). If you really want to study the subject, check out the SELinux notebook (https://bit.ly/3GxGhkm).

Seccomp

seccomp is a Linux kernel mechanism that limits the number of syscalls to a group of processes on the system. You can remove potentially dangerous syscalls from being called by the processes.

The seccomp man page is a good source of additional information on seccomp (https://bit.ly/3rnnim1).

User namespace

The user namespace allows you to have Linux capabilities within the group of UIDs and GIDs assigned to the namespace, without having root capabilities on the host.

The user namespace is fully explained in chapter 3.

Compare cgroup-based resource constraints with the Linux capabilities, SELinux, and seccomp mechanisms that complete the container isolation model. section 1.2

How Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more covers it

How deep it goes
Defines hierarchical grouping and names resource examples, then connects cgroups to pods and systemd process tracking.
Examples
Uses memory, CPU, and network constraints, pod-level sharing, and systemd service scopes as concrete examples.
What it assumes
Assumes basic familiarity with Linux processes and containers while defining cgroups before applying them to Podman and systemd.
What you can do after
Operate and configure Podman services with systemd while understanding cgroup-based resource and process management.
How it connects
Connects cgroups with containers, pods, Linux namespaces, Podman, systemd, and kernel security mechanisms.

Also explained in

Compare how 3 books explain cgroup →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more. The section links point to the parts of the book it draws on.