liveBook · Manning

Pid namespace

As explained in Kubernetes in Action, Second Edition

A PID namespace is a Linux isolation scope that gives processes an isolated view of process identifiers and process hierarchy.

A PID namespace isolates process identifiers and process hierarchies. A container therefore sees its own process tree instead of the host’s or another container’s processes, while the host still sees those processes as ordinary host processes. section 2.3.2 section 2.3.1

A PID namespace creates several practical distinctions:

  • The container’s main process commonly appears as PID 1 inside the container, while the same process has a different PID in the host namespace. section 2.3.2
  • Processes in separate PID namespaces cannot see one another in process listings or send signals such as SIGTERM or SIGINT. section 5.1.1
  • A pod uses separate process namespaces by default; setting shareProcessNamespace to true gives all its containers one process tree. section 5.3.6

Compare process views

Run ps aux inside a container and see only its small process list, such as node app.js, a shell, and ps. Run ps aux on the host and find the same application process under a different, host-level PID. For pod debugging, set shareProcessNamespace: true and use an ephemeral container; ps then shows the application, sidecar, shell, and pause processes together.

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains namespace visibility, dual PIDs, process trees, and pod sharing, but does not detail kernel implementation.
Examples
Demonstrates container and host ps output, Docker shells, ephemeral debugging containers, and shareProcessNamespace manifests.
What it assumes
Introduces namespaces and process isolation from basic container commands without requiring prior namespace knowledge.
What you can do after
Diagnose process visibility by comparing container and host ps output, or configure pod-wide visibility for debugging.
How it connects
Connects Linux namespaces with containers, process trees, pods, ephemeral containers, and process signals.

Also explained in

Compare how 2 books explain pid namespace →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.