LinuxCommandLibrary

namespaces

TLDR

List all namespaces

$ lsns
copy
Enter namespace of process
$ nsenter -t [PID] -a
copy
Create new mount namespace
$ unshare --mount [command]
copy
Create new network namespace
$ ip netns add [name]
copy
Run in new user namespace
$ unshare --user --map-root-user [command]
copy

SYNOPSIS

namespaces - Linux kernel namespace overview

DESCRIPTION

Namespaces are a Linux kernel feature that partitions kernel resources so that processes see different views of the system. They are fundamental to container technologies like Docker.
Each namespace type isolates a different aspect of the system.

NAMESPACE TYPES

$ mnt   - Mount points
pid   - Process IDs
net   - Network stack
ipc   - System V IPC
uts   - Hostname/domain
user  - User/group IDs
cgroup - Cgroup root
time  - System time
copy

RELATED TOOLS

$ unshare   - Create new namespace
nsenter   - Enter existing namespace
lsns      - List namespaces
ip netns  - Network namespace management
copy

SYSTEM CALLS

$ clone()    - Create new namespace
unshare()  - Disassociate from namespace
setns()    - Join namespace
copy

CAVEATS

Some operations require root/capabilities. Namespace limits exist. User namespaces have security implications.

HISTORY

Namespaces were incrementally added to Linux starting with mount namespaces in kernel 2.4.19 (2002). Full container support matured around kernel 3.8 (2013).

SEE ALSO

unshare(1), nsenter(1), lsns(8), cgroups(7)

Copied to clipboard