The problem
A Linux host runs a website, database and student-submitted programs. A busy or compromised program should not freely interfere with the others. A separate VM for each is one answer, but each guest brings its own kernel and virtual-machine environment.
When the programs can share Linux, process isolation can provide separate environments within the host kernel. Two different questions must be answered:
| Question | Mechanism |
|---|---|
| What system resources and identifiers can the processes see and use? | Namespaces, together with permissions and configuration |
| How much controlled resource capacity may they consume? | Cgroups |
Namespaces are enforced environments, not merely hidden labels. For example, port bindings in different network namespaces do not occupy the same binding space. However, different network views do not give processes different physical CPUs or RAM.
Assemble an environment
For an illustrative student-code workload, a runtime can create selected namespaces, prepare filesystem mounts and networking, assign cgroup controls, restrict privileges and start the program. The program and its workers remain host-kernel processes.
VM: application -> guest kernel -> virtual hardware
Container: application -> shared host kernelNamespaces are independent choices. A process can have separate PID and mount namespaces while sharing the host’s network namespace. Creating one namespace does not automatically configure the others or impose resource limits.
The room/budget analogy is useful: namespaces arrange rooms and what is reachable in them; cgroups assign resource budgets. Its limit is that the rooms still share the kernel and physical capacity. Isolation quality depends on the complete configuration and security boundary, not the analogy.
Creating or joining namespaces
| Interface | Conceptual operation |
|---|---|
clone() with CLONE_NEW* flags | Create a child with selected new namespaces |
unshare() | Stop sharing selected environment components and create new namespaces |
setns() | Join an existing namespace where permitted |
PID namespaces have a special rule: unshare()/setns() select the namespace for later children rather than renumbering the caller. Flags can be combined to request several namespace types. Linux namespace API.
Kernel partitioning is not necessarily kernel duplication
The PDF’s page 12 diagram illustrates separate interface lists and routing tables selected according to namespace membership. The same kernel handles each operation using the relevant resource instance. It is not running one kernel per namespace.
The seven types on PDF page 13 are the source’s list. It is not a timeless exhaustive count: the Linux manual also documents time namespaces. Likewise, the slide’s blanket claim that a root namespace sees all resources must be qualified by namespace type. PID ancestry gives hierarchical visibility; network namespaces do not have that same visibility hierarchy.
Retrieval practice
A service has a private network namespace but monopolizes memory. What is missing? Resource controls. The network view does not cap memory consumption; see Linux Cgroups - Weights Quotas and Memory Limits.
Two isolated environments each report PID 1. Are there two kernels? No. Different PID views can describe processes using the same host kernel.
Does applying every namespace guarantee complete security? No. Permissions, exposed files/devices, resource policies, kernel behavior and other security controls still matter. Some deployments intentionally share particular namespaces.
Source and related concepts
Lecture 06 - Lightweight Virtualization - Cgroups and Namespaces, PDF pages 3-5, 7, 10-14, 29 and 35. Container assembly and comparisons are added study explanations. The lecture closes by introducing containers/Docker as tools for reducing configuration complexity, rather than presenting a Docker tutorial.