这是本专栏的第二部分:容器篇,共 8 篇,帮助大家由浅入深地认识和掌握容器。前面,我为你介绍了容器生命周期和资源管理相关的内容,让你对容器有了更加灵活的控制。之后从进程的角度带你认识了容器以及容器核心技术之一的 cgroups。本篇,我来为介绍容器的另一项核心技术:namespace。
什么是 namespace
我们仍然以 Wiki 上对 namespace 的定义开始:
Namespaces are a feature of the Linux kernel that partitions kernel resources such that one set of processes sees one set of resources while another set of processes sees a different set of resources. The feature works by having the same namespace for these resources in the various sets of processes, but those names referring to distinct resources.
namespace 是 Linux 内核的一项功能,它可以对内核资源进行分区,使得一组进程可以看到一组资源;而另一组进程可以看到另一组不同的资源。该功能是在各种进程集中对这些资源使用相同的 namespace,但是这些名称引用不同的资源。
这样的说法未免太绕了些,简单来说 namespace 是由 Linux 内核提供的,用于进程间资源隔离的一种技术。同时