liveBook · Manning

Linux namespace

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

A Linux kernel isolation mechanism that provides a process with a separate view of selected system resources.

A Linux namespace is a kernel isolation mechanism that creates a virtualized environment where processes see selected resources while remaining separated from the host and other containers. section 1.2

Container isolation commonly combines several namespace types:

  • Network namespaces hide the host network while exposing virtual network devices. section 1.2
  • Mount namespaces hide the host filesystem and expose the container filesystem. section 1.2 section 10.0
  • PID namespaces hide host processes so container processes see processes within their container. section 1.2 section 10.0
  • IPC and user namespaces further separate operating-system resources and map container root to a limited host identity. section 10.0 section 1.2

Namespaces provide a virtual-machine-like view without virtual-machine overhead, but they are one layer of container security. Podman also relies on cgroups, dropped capabilities, SELinux, seccomp, and protected kernel filesystems. section 1.2 section 10.0

Avoiding privileged mode

When a container is denied access, diagnosing the relevant namespace or security boundary is safer than immediately using --privileged, which turns off all security separation. section 10.0

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.

Review the related Linux security mechanisms that complement namespace isolation, including capabilities, SELinux, and seccomp. section 1.2

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

How deep it goes
Explains virtualized resource views and several namespace types, but defers detailed kernel configuration and runtime implementation.
Examples
Uses network, mount, PID, IPC, and user namespaces, plus the --privileged option as a security counterexample.
What it assumes
Assumes familiarity with Linux processes and kernel resources while defining namespace terminology from its isolation purpose.
What you can do after
Evaluate container isolation boundaries and avoid disabling them unnecessarily with --privileged.
How it connects
Connects namespaces with cgroups, SELinux, seccomp, Linux capabilities, user namespaces, and Podman.

Also explained in

Compare how 2 books explain linux namespace →

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.