Skip to content

Commit ef0a8f9

Browse files
committed
post: update docker engine
1 parent 3317b90 commit ef0a8f9

File tree

17 files changed

+2572
-137
lines changed

17 files changed

+2572
-137
lines changed

content/posts/2025-09-04_docker-engine.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
+++
22
date = '2025-09-04T8:00:00+08:00'
33
draft = false
4-
title = 'Docker - Engine'
4+
title = 'Docker - Engine and Netowrking'
55
tags = ['Docker']
66
+++
77

8-
Docker 引擎(Docker Engine), 顾名思义,是 Docker 的核心.
8+
Docker 引擎(Docker Engine), 顾名思意,是 Docker 的核心.
99
它为 Docker 提供动力, 并承担所有繁重的工作.
1010
本文将深入探讨这一关键组件的内部运作, 以便了解 Docker 在内核下是如何工作的.
1111

@@ -122,11 +122,44 @@ docker-init 会捕捉这些信号, 并适当地转发, 保证容器内的应用
122122

123123
总之, docker-init 确保容器保持干净, 响应迅速并得到良好管理. 它不一定显眼, 但正是这些细小的贡献让容器变得可靠且高效.
124124

125-
#### Conclusion 结论
125+
### Network Ports and Unix Sockets 网络端口和Unix套节字
126+
Docker CLI 和 docker daemon 可以通过 Unix Sockets 和 network ports 沟通. Docker, Inc. 已经向 Internet Assigned Numbers Authority(IANA)注册了3个端口, 用于Docker daemon 和 client:
127+
- TCP port 2375 用于未加密连接
128+
- port 2376 用于 SSL 加密连接
129+
- port 2377 用于 Docker Swarm mode
130+
131+
在需要使用不同设置的场景下, 更换端口配置很容易.
132+
Docker 安装程序的默认设置是只使用 Unix 套接字与本地 Docker 守护进程通信.
133+
这样做可以确保系统默认采用尽可能安全的安装方式.
134+
这个选项同样可以方便地修改, 但强烈建议不要用网络端口来暴露 Docker, 因为 Docker 守护进程内部并没有用户认证和基于角色的访问控制.
135+
Unix 套接字在不同操作系统的路径可能不同, 但在大多数情况下可以在 `/var/run/docker.sock` 找到.
136+
137+
### Container Networking 容器网络
138+
尽管 Linux 容器在很大程度上是宿主机上运行的进程, 但在网络层他们通常表现得与其他进程很不一样.
139+
Docker 最初只支持一种网络模型, 但现在提供了多种稳健的配置, 可以曼珠大多数应用的需求.
140+
大多数人以默认配置运行容器, 这称为桥接模式 Bridge Mode.
141+
142+
要理解桥接模式, 最容易是把每个 Linux 容器看作是在私有网络上的一台主机.
143+
Docker 服务器充当一个虚拟桥 virtual bridge, 容器则是作为桥后的客户端.
144+
桥只是一个把一侧流量转发到另一侧的网络设备.
145+
因此, 可以将它想象成一个虚拟网络, 每个容器像附着在该网络上的主机.
146+
实际上是: 每个容器都有一个虚拟以太网接口连接到 Docker 桥, 并未该虚拟接口分配一个 IP 地址.
147+
Docker 运行在宿主机上绑定并暴露单个或一组端口到容器, 以便外部世界可以通过这些端口访问容器, 流量很大程度上由 vpnkit 库来管理.
148+
149+
Docker 从 未使用的 RFC 1918 私有子网块中分配私有子网, 它检测主机上有哪些网络块未被使用, 并把其中一个分配给虚拟网络.
150+
该网络通过服务器上的一个名为 docker0 的接口桥接到宿主机的本地网络.
151+
这意味着默认情况下, 所有容器都在同一个网络中, 可以直接相互通信.
152+
但要达到宿主机或外部网络, 他们会通过 docker0 虚拟桥接接口转发出去.
153+
154+
![docker container network](../render-image/2025-09-04_docker-container-network.png)
155+
156+
有多种方式配置 Docker 的网络层, 从分配自己的网络块到配置自定义桥接接口, 方式繁多让人眼花缭乱.
157+
人们通常使用默认机制, 但有时需要更复杂或更贴合应用的配置.
158+
159+
### Summary 总结
126160
Docker 引擎不仅仅是一款软件, 它是一套精心设计的模块化组件系统, 这些组件协同工作以实现容器的高效、可扩展与可移植.
127161
从 CLI 中敲下命令, 到 runc、shim、docker-init 所处理的底层操作, 每个元素都扮演者明确且重要的角色.
128162

129163
通过遵守严格的 OCI 标准, Docker 确保其生态系统不仅强大, 且具备通用兼容性. 这种遵循标准的做法建立了信任, 为开发者与企业提供了稳定的基础, 模块化架构简化了容器管理, 并鼓励创新, 允许每个组件独立演进与改善.
130164

131165
理解 Docker 引擎不仅是知道容器如何工作, 更是认识其背后经过深思熟虑的工程设计. 正是这种工程让现代软件开发更快、更高效、更容易上手.
132-
Docker 不只是一个工具, 它是一个赋能平台, 开启无限可能.
147 KB
Loading
147 KB
Loading

public/archives/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
min</span></div></div></div></div></article><article class="group bg-card border-border hover:bg-accent/50 rounded-lg border p-4 transition-all duration-300"><div class="flex items-center justify-between gap-4"><div class="min-w-0 flex-1"><h4 class="text-foreground group-hover:text-primary mb-3 font-medium transition-colors duration-200"><a href=/posts/docker-images-and-registeries/ class=block>Docker - Images and Registeries</a></h4><div class="text-muted-foreground flex items-center gap-4 text-xs"><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
6464
<time datetime=2025-09-05>09-05</time></div><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3A9 9 0 113 12a9 9 0 0118 0z"/></svg>
6565
<span>6
66-
min</span></div></div></div></div></article><article class="group bg-card border-border hover:bg-accent/50 rounded-lg border p-4 transition-all duration-300"><div class="flex items-center justify-between gap-4"><div class="min-w-0 flex-1"><h4 class="text-foreground group-hover:text-primary mb-3 font-medium transition-colors duration-200"><a href=/posts/docker-engine/ class=block>Docker - Engine</a></h4><div class="text-muted-foreground flex items-center gap-4 text-xs"><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
66+
min</span></div></div></div></div></article><article class="group bg-card border-border hover:bg-accent/50 rounded-lg border p-4 transition-all duration-300"><div class="flex items-center justify-between gap-4"><div class="min-w-0 flex-1"><h4 class="text-foreground group-hover:text-primary mb-3 font-medium transition-colors duration-200"><a href=/posts/docker-engine-and-netowrking/ class=block>Docker - Engine and Netowrking</a></h4><div class="text-muted-foreground flex items-center gap-4 text-xs"><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
6767
<time datetime=2025-09-04>09-04</time></div><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3A9 9 0 113 12a9 9 0 0118 0z"/></svg>
68-
<span>6
68+
<span>8
6969
min</span></div></div></div></div></article><article class="group bg-card border-border hover:bg-accent/50 rounded-lg border p-4 transition-all duration-300"><div class="flex items-center justify-between gap-4"><div class="min-w-0 flex-1"><h4 class="text-foreground group-hover:text-primary mb-3 font-medium transition-colors duration-200"><a href=/posts/docker-history/ class=block>Docker - History</a></h4><div class="text-muted-foreground flex items-center gap-4 text-xs"><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5A2 2 0 003 7v12a2 2 0 002 2z"/></svg>
7070
<time datetime=2025-09-03>09-03</time></div><div class="flex items-center gap-1"><svg class="h-3 w-3" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3A9 9 0 113 12a9 9 0 0118 0z"/></svg>
7171
<span>4

public/en/sitemap.xml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)