Namespace
Last updated
Last updated
A namespace wraps a global system resource in an abstraction that makes it appear to the processes within the namespace that they have their own isolated instance of the global resource.
We can use various system calls to create, or join a new, or an existing namespace.
The clone
(2) system call creates a new process.
If the flags argument of the call specifies one or more of the CLONE_NEW*
flags listed below, then new namespaces are created for each flag, and the child process is made a member of those namespaces.
The kernel assigns each process a symbolic link per namespace kind in /proc/<PID>/ns/
. Since Linux 3.8, these files appear as symbolic links.
If two processes are in the same namespace, then the device IDs and inode numbers of their /proc/<pid>/ns/xxx
symbolic links will be the same. We can check this using the stat.st_dev
and stat.st_ino
fields returned by stat(2).
We can use readlink
to read the content of the symbolic link:
Type | Flag used in APIs | Man Page | Isolates |
---|---|---|---|
Cgroup |
|
| Cgroup root directory |
IPC |
|
| System V IPC, POSIX message queues |
Network |
|
| Network devices, stacks, ports, etc. |
Mount |
|
| Mount points |
PID |
|
| Process IDs |
Time |
|
| Boot and monotonic clocks |
User |
|
| User and group IDs |
UTS |
|
| Hostname and NIS domain name |