Lukas' Notes

operating-systems virtualisation

Definition

Namespace

A namespace is a Linux kernel abstraction that wraps a global system resource so that processes inside the namespace see an isolated instance of that resource.

Changes made to the resource are visible to other processes in the same namespace but are invisible to processes outside it.

Namespaces are the foundation of Linux OS-level virtualisation and were introduced in 2008.

Types

Namespace types

TypeIsolated resourceExample
mntfile system mount pointseach container has its own /tmp or /var
pidprocess IDseach container has its own init (PID 1) and /proc
netnetwork interfaces, routing, firewalleach container has its own loopback device
ipcinter-process communicationtwo containers can create shared memory with the same name
utshostname and domain nameeach container has its own hostname
cgroupcontrol group viewprocesses in a container cannot see host cgroup directories
useruser and group IDs, capabilitiesroot inside a container may be an unprivileged user outside

Creating namespaces

The unshare command can create a new namespace and run a program inside it.