liveBook · Manning

Mount namespace

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

A mount namespace is a Linux namespace that isolates the filesystem mount view available to a process group.

A mount namespace isolates the filesystem mount view available to a process group. Container processes see only the filesystem content assigned to their namespace, rather than the host filesystem. section 10.7 section 1.2

Podman creates a rootfs mount point, bind-mounts the container’s volumes onto it, and invokes the OCI runtime. The runtime uses pivot_root to make rootfs the namespace’s root, causing the host operating system’s filesystems to disappear from the container view. section 10.7

Mount namespaces form part of a layered container security boundary:

  • A user namespace supplies the permissions needed for rootless Podman to create and mount filesystems. section 6.1.1 section 6.3
  • Dropping CAP_SYS_ADMIN prevents processes inside the container from changing rootfs mounts to expose underlying filesystems. section 10.7
  • SELinux provides an additional defense against escapes that defeat namespace isolation, including runtime vulnerabilities. section 10.7 section 10.0

Inspecting and testing the mount namespace

Compare the namespace identifiers with `ls -l /proc/self/ns/mnt` and `podman unshare ls -l /proc/self/ns/user /proc/self/ns/mnt`. A mount that requires host privilege can succeed inside both namespaces: `podman unshare bash -c "mount -o bind /tmp/testfile /etc/shadow; cat /etc/shadow"`. The result is visible through the namespaced process, not as unrestricted host filesystem access.

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

How deep it goes
Explains rootfs, bind mounts, pivot_root, and CAP_SYS_ADMIN, while deferring escape resistance to SELinux and runtime security.
Examples
Demonstrates namespace identifiers with /proc, mounts /tmp/testfile over /etc/shadow using podman unshare, and inspects rootless mount support.
What it assumes
Assumes Linux process and filesystem basics, while introducing user namespaces, rootfs, bind mounts, pivot_root, and capabilities.
What you can do after
Operate Podman’s rootless isolation demonstrations and evaluate how filesystem visibility, capabilities, and SELinux constrain container processes.
How it connects
Connects user namespaces, bind mounts, OCI runtime, pivot_root, Linux capabilities, SELinux, and rootless containers.

Also explained in

Compare how 2 books explain mount 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.