3. Namespace
Namespace
Each container operates in an independent space without knowing the existence of other containers running on the same host, and this property is expressed as being isolated. This isolation characteristic of containers is implemented using the Namespace function of the Linux kernel. Namespace refers to the isolated space to which a process belongs.
|
|
|
|
|
|
[Shell 1~3] shows the process of running nginx Container and httpd Container inside one Host to experiment with the isolation characteristics of Namespace through containers, then checking Process, Network, Hostname, and Mount information inside the Host and each Container. Although nginx Container and httpd Container are running inside the same Host, you can see that they have different Process, Network, Hostname, and Mount information. This phenomenon occurs because Host, nginx Container, and httpd Container are using different Namespaces. More specifically, it is because the processes of Host, nginx Container, and httpd Container belong to different Namespaces.
Namespace Type
There are various types of Namespaces depending on what they isolate. Representative Namespace types are as follows:
- PID Namespace : Isolates PID (Process ID).
- Network Namespace : Isolates Network.
- Mount Namespace : Isolates Mount information.
- UTS Namespace : Isolates Hostname.
- IPC Namespace : Isolates IPC (Interprocess Communication).
- UID Namespace : Isolates UID (User ID).
![[Figure 1] Host, Container Namespace](/blog-software/series/onebyone-container/3-namespace/images/namespace.png)
[Figure 1] Host, Container Namespace
Each process must belong to a Namespace of all Namespace types. Therefore, the relationship between the Namespace and Process of Host and nginx, httpd Container used as examples in [Shell 1~3] becomes as shown in [Figure 1]. Except for PID Namespace, you can see that the Host’s processes belong to each Namespace owned by the Host, and the processes of nginx and httpd Container belong to each Namespace owned by nginx and httpd Container. The relationship between PID Namespace and Process will be explained in more detail when explaining PID Namespace. In addition, Network Namespace and Mount Namespace, which must be understood, will also be explained in detail later.