liveBook · Manning

Chapter 10: Security container isolation

What you will learn in chapter 10 of Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

The chapter introduces container security as protecting the shared host kernel and filesystem, then previews the isolation features Podman uses to do so.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces container security as protecting the shared host kernel and filesystem, then previews the isolation features Podman uses to do so.

Key terms: host kernel, host filesystem, container processes, The Container Coloring Book, --privileged, security separation, read-only access, masking, Linux capabilities, PID namespace

10.1 Read-only Linux kernel pseudo filesystems

This section explains how Podman limits a container’s access to kernel pseudo filesystems through read-only mounts, a namespaced /proc, and masked paths.

Key terms: kernel pseudo filesystems, /proc, /sys, CAP_SYS_ADMIN, read only, PID namespace, masked paths, /dev/null, read-only tmpfs, bind mounts

10.1.1 Unmasking the masked paths

Shows how to expose masked pseudo-filesystem paths selectively without disabling all container security.

Key terms: --security-opt unmask=/proc/scsi, /proc/scsi, tmpfs, *, --privileged, unmasking

10.1.2 Masking additional paths

This subsection shows how to mask an additional pseudo-filesystem path in a Podman container and raises the question of whether container root can undo such mounts.

Key terms: --security-opt mask, masked paths, /proc/sys/dev, /proc/self/mountinfo, remounting filesystems read/write

10.2 Linux capabilities

This section introduces Linux capabilities as a way to divide root privileges, shows how to inspect a process’s capabilities, and explains why containers rarely need the full set.

Key terms: root, setuid, Linux capabilities, capsh, current set of capabilities, Bounding set, sudo, containers, kernel

10.2.1 Dropped Linux capabilities

This section shows how Podman limits container root by dropping most Linux capabilities while retaining a small set needed by common applications.

Key terms: Linux capabilities, root, capsh, default_capabilities, containers.conf, CAP_SETUID, CAP_SETGID, CAP_NET_BIND_SERVICE, UID, CAP_SYS_ADMIN

10.2.2 Dropped CAP_SYS_ADMIN

This subsection explains why Podman drops the broad CAP_SYS_ADMIN capability by default and why containers may need even fewer capabilities than Podman allows.

Key terms: CAP_SYS_ADMIN, mount and unmount filesystems, read-only mount points, 11 capabilities, dropping capabilities

10.2.3 Dropping capabilities

This section shows how to reduce a container's privileges by dropping Linux capabilities and notes when a required capability may need to be added back.

Key terms: least privileges, --cap-drop=CAP_NET_BIND_SERVICE, --cap-drop=all, root, capabilities, modify the kernel

10.2.4 Adding capabilities

This section shows how to give a container one needed Linux capability without disabling its other security protections.

Key terms: --privileged, --cap-add, --cap-drop, CAP_NET_RAW, raw IP packet

10.2.5 No new privileges

This subsection explains how Podman’s no-new-privileges option prevents container processes from gaining capabilities or changing SELinux labels.

Key terms: --security-opt no-new-privileges, Linux capabilities, setuid, SELinux label transitions

10.2.6 Root with no capabilities is still dangerous

Dropping Linux capabilities improves container security, but a root process can still pose risks that user namespaces help address.

Key terms: Linux capabilities, root, user namespace

10.3 UID isolation: User namespace

This section explains how rootless Podman maps container UIDs to host UIDs, why that avoids host-root processes, and what risk remains when containers share a user namespace.

Key terms: user namespace, UIDs, /etc/subuid, /etc/subgid, rootless Podman, duplicate UIDs, home directory, rootless users

10.3.1 Isolating containers using the - -userns=auto flag

This section shows how Podman’s --userns=auto option assigns separate UID ranges to containers, sizes those ranges, and reuses them after removal.

Key terms: --userns=auto, /etc/subuid, /etc/subgid, UIDs, GIDs, UID range, /etc/passwd, default minimum of 1024, user namespace, --userns=auto:size=5000

10.3.2 User-namespaced Linux capabilities

This section explains why Linux capabilities inside a user namespace give container root limited authority, and demonstrates the limit with network administration and file ownership.

Key terms: Linux capabilities, user namespace, namespaced capabilities, CAP_NET_ADMIN, network namespace, CAP_CHOWN, chown, mapped UID, --userns=auto

10.3.3 Rootless Podman with the - -userns=auto flag

Explains how automatic user namespaces map UIDs in rootless Podman, the limits of the available UID range, and the risk of overlapping mappings.

Key terms: --userns=auto, rootless user namespace, UID, UIDs, high range of UIDs

10.3.4 User volumes with the - -userns=auto flag

This subsection explains why user namespaces complicate volume ownership and compares Podman’s U and idmap mount options for making a volume accessible.

Key terms: user namespace, UID, volume, --volume, U, chown, source directory, primary process, idmapped mounts, idmap

10.4 Process isolation: PID namespace

This section explains how Podman’s default PID namespace hides host processes from containers and what changes when a container uses the host PID namespace.

Key terms: PID namespace, process isolation, information masking, --pid=host, SELinux separation, dropped capabilities, user namespaces

10.5 Network isolation: Network namespace

This section shows how Podman network namespaces isolate containers on separate networks and how host networking bypasses that isolation.

Key terms: network namespace, podman network create, --network, net1, net2, --net=host, host network

10.6 IPC isolation: IPC namespace

This section explains how IPC namespaces isolate container communication resources and how Podman can deliberately share those resources between containers or with the host.

Key terms: IPC namespace, System V IPC objects, POSIX message queues, /dev/shm tmpfs, --ipc=container:NAME, pod, --ipc=host, SELinux label, SELinux separation

10.7 Filesystem isolation: Mount namespace

This section explains how Podman hides the host filesystem with a mount namespace and why SELinux and rootless operation remain important safeguards.

Key terms: mount namespace, rootfs, bind mounts, OCI runtime, pivot_root, CAP_SYS_ADMIN, SELinux, rootless Podman, runc, CVE-2019-5736

10.8 Filesystem isolation: SELinux

Introduces SELinux’s label-based filesystem isolation, the two enforcement mechanisms containers use, and where SELinux is available.

Key terms: SELinux, labels, type enforcement, MCS enforcement, categories, Fedora, RHEL, Debian-based distributions, Ubuntu

10.8.1 SELinux type enforcement

This section explains how SELinux type labels let container processes use their own files while blocking access to differently labeled host files, and where type enforcement stops protecting containers.

Key terms: SELinux label, type, container_t, container_file_t, SELinux policy, ssh_home_t, user_home_t, Permission denied, volume, z

10.8.2 SELinux Multi-Category Security separation

This section explains how Podman uses SELinux MCS labels to separate containers, how volume relabeling controls sharing, and how to disable SELinux container labeling when relabeling is inappropriate.

Key terms: Multi-Category Security (MCS), type enforcement, process label, filesystem label, categories, MCS level, dominance, s0, :Z, container private label

10.9 System call isolation seccomp

This section explains how Podman uses seccomp to restrict container system calls, reducing opportunities to exploit the host kernel.

Key terms: syscall, seccomp, Linux kernel, /usr/share/containers/seccomp.json, capabilities, seccomp filters, mkdir, seccomp.json, --security-opt seccomp=unconfined

10.10 Virtual machine isolation

This section explains how running containers in lightweight virtual machines strengthens isolation and what resource-sharing costs come with it.

Key terms: OCI runtimes, Kata, libkrun, Kernel-based Virtual Machine (KVM), lightweight virtual machine, VM isolation, memory management, CPU, sharing volumes

10.11 Summary

The summary identifies what container security protects and why layering security mechanisms matters.

Where this is used later

Concepts explained in this chapter

← Chapter 9: Podman as a service Chapter 11: Additional security considerations →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.