Namespaces are a feature of the Linux kernel that partition kernel resources such that one set of processes sees one set of resources, while another set of processes sees a different set of resources. The feature works by assigning the same namespace type to a set of resources and processes, but allowing those namespaces to refer to distinctly isolated environments. This provides the illusion that a process or a process group is the sole user of the system's hardware and software resources. Examples of such resources include process IDs, hostnames, user IDs, file names, network interfaces, and inter-process communication (IPC) mechanisms. Linux namespaces, alongside cgroups (control groups), are the foundational technologies underpinning modern OS-level virtualization and Linux containerization platforms such as Docker, Kubernetes, LXC, and Podman. While cgroups dictate how much of a system's resources a process can use (such as CPU, memory, and disk I/O limits), namespaces dictate what a process is allowed to see and interact with. The term "namespace" is often used to denote a specific type of namespace (e.g., process ID namespace) as well as a particular space of names. A Linux system begins with a single initial namespace of each type, which is shared by all processes. Processes can subsequently create additional namespaces or join existing ones, allowing complex, nested isolation boundaries.
History Linux namespaces were heavily inspired by the wider namespace functionality utilized throughout the Plan 9 from Bell Labs operating system, which treated everything as a file and provided per-process namespace isolation. The Linux namespace implementation originated in 2002 with the release of the 2.4.19 kernel. The first namespace introduced was the mount namespace, pioneered by kernel developer Al Viro, which isolated filesystem mount points. Because it was the first of its kind, the system call flag introduced for it was simply named CLONE_NEWNS (New Namespace), a name that does not specify "mount" and is often considered a historical artifact. Subsequent namespaces were introduced progressively over several years:
UTS and IPC namespaces were added in kernel version 2.6.19 in 2006. PID namespaces were finalized in kernel 2.6.24 in 2008. Network namespaces were largely completed by kernel 2.6.29 in 2009. User namespaces, primarily developed by Eric W. Biederman, were considered complete and functional in kernel version 3.8, released in 2013. The introduction of user namespaces was a milestone, as it enabled the creation of "unprivileged containers"—containers that can run safely without requiring underlying superuser (root) privileges on the host system. Cgroup namespaces were introduced in kernel 4.6 in March 2016, spearheaded by Tejun Heo. Time namespaces were merged in kernel version 5.6 in March 2020, allowing containers to have their own monotonic and boot times.
Namespace kinds As of Linux kernel version 5.6, there are exactly eight kinds of namespaces. Namespace functionality operates uniformly across all kinds: each process is associated with a namespace and can only see or use the resources associated with that specific namespace, including its descendant namespaces where applicable. This provides each process (or group of processes) with a unique, compartmentalized view of the system.
Mount (mnt) Mount namespaces, the first namespace to be added to Linux, control mount points. They provide a process with an isolated view of the filesystem hierarchy. Upon creation, the mounts from the current mount namespace are initially copied to the new namespace. However, mount points created or unmounted afterwards do not propagate between namespaces by default. Using the Linux shared subtrees feature, it is possible to configure specific mount points to propagate events (such as a USB drive being mounted) between the host and the container, or vice versa. The clone flag used to create a new namespace of this type is CLONE_NEWNS.
Process ID (pid) The PID namespace provides processes with an independent set of process IDs (PIDs). PID namespaces are strictly nested. When a new process is created within a new PID namespace, it will have a distinct PID for each namespace from its current namespace up to the initial (root) PID namespace. Hence, processes in the initial PID namespace (like the host operating system) are able to see all processes across all containers, albeit with different PIDs than those seen inside the containers. The first process created in a PID namespace is assigned process ID number 1. It receives much of the same special treatment as the host system's normal init process. Most notably, any orphaned processes within the namespace are automatically reparented to this PID 1 process. If this PID 1 process terminates, the kernel will immediately terminate all other processes within that PID namespace and any of its descendants by sending them a SIGKILL signal.
Network (net) Network namespaces virtualize the network stack. Upon creation, a new network namespace contains only a loopback interface (lo), which is initially down. Each network interface—whether physical or virtual—can only be present in exactly one network namespace at a time, but interfaces can be actively moved between namespaces by an administrator. Each network namespace maintains a private set of IP addresses, its own routing table, socket listing, connection tracking table, firewall rules (such as iptables or nftables), and other network-related resources. To grant a container network connectivity, administrators typically create a Virtual Ethernet (veth) pair, placing one end in the host namespace and the other inside the container's network namespace, and then bridge the host end to a physical network. Destroying a network namespace automatically destroys any virtual interfaces within it and moves any physical interfaces back to the initial network namespace.
Inter-process Communication (ipc) IPC namespaces isolate processes from SysV style inter-process communication mechanisms, as well as POSIX message queues. This prevents processes in different IPC namespaces from interacting with each other using common IPC identifiers. For example, two processes in different namespaces can use the same shared memory segment identifier to allocate memory via the SHM family of functions, and the kernel will guarantee that they are provided with two distinct, fully isolated regions of shared memory.
… excerpt ends here. Continue reading the full article.