Skip to content

Commit

Permalink
updatge
Browse files Browse the repository at this point in the history
  • Loading branch information
isno committed Mar 11, 2024
1 parent 299f4f9 commit ccbc57a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion container/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@

## 容器的本质是隔离的进程

那么,容器是本质什么呢?如果吧 Kubernetes 比作云原生时代的操作系统,那么容器就是这个操作系统之内的特殊进程。
那么,容器是本质什么呢?如果把 Kubernetes 比作云原生时代的操作系统,那么容器就是这个操作系统之内的特殊进程。

特殊之处在于容器利用一些内核技术,如 namespace 对其视图进行隔离,cgroup(约束能用多少资源,内存/磁盘。cpu等)对其资源使用进行约束。

:::tip namespace

namespace 的早期提出以及使用要追溯到贝尔实验室开发的一个名叫 Plan 9 的分布式操作系统。最初的目的是为了实现文件的隔离,并非为了容器而设计。

后来系统隔离的呼声愈发强烈,Linux 内核从 2.4.19 起,陆续添加了 Mount、UTS、IPC、PID、Network 等 namespace 隔离功能。到 Linux 3.8,又增加了 User namespace。至此,Docker 以及其他容器技术所用到的 namespace 已全部就绪。

:::

使用 Namespace 其实也非常简单,它其实只是 Linux 创建新进程的一个可选参数。比如,在 Linux 系统中创建线程的系统调用是 clone。
```
int clone(int (*fn)(void *), void *child_stack,
Expand Down

0 comments on commit ccbc57a

Please sign in to comment.