Docker 使用 Linux kernel 功能 — namespaces(隔离)、cgroups(资源控制)和 union filesystems(分层镜像)— 来创建轻量级容器。理解底层机制解释了容器如何实现隔离和效率。
Namespaces — 隔离
Linux NAMESPACES isolate what a process can SEE — giving each container its own view:
PID namespace → its own process tree (container sees only its processes)
NET namespace → its own network interfaces, IPs, ports
MNT namespace → its own filesystem mounts
UTS namespace → its own hostname
IPC, USER namespaces → isolated IPC, user/group ID mapping
→ Namespaces are WHY a container feels like a separate machine (isolated view),
while actually sharing the host kernel.
