直接回答:执行 kill -SIGHUP $(pidof dockerd) 就能让 Docker 守护进程热加载配置,容器不会中断;但只有 debug、labels、live-restore、cluster-store 等少数配置项支持热加载。

热更新代码

1
sudo kill -SIGHUP $(pidof dockerd)

支持热更新的操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

debug: it changes the daemon to debug mode when set to true.

cluster-store: it reloads the discovery store with the new address.

cluster-store-opts: it uses the new options to reload the discovery store.

cluster-advertise: it modifies the address advertised after reloading.

labels: it replaces the daemon labels with a new set of labels.

live-restore: Enables keeping containers alive during daemon downtime.

max-concurrent-downloads: it updates the max concurrent downloads for each pull.

max-concurrent-uploads: it updates the max concurrent uploads for each push.

default-runtime: it updates the runtime to be used if not is specified at container creation. It defaults to “default” which is the runtime shipped with the official docker packages.

runtimes: it updates the list of available OCI runtimes that can be used to run containers.

authorization-plugin: it specifies the authorization plugins to use.

allow-nondistributable-artifacts: Replaces the set of registries to which the daemon will push nondistributable artifacts with a new set of registries.

insecure-registries: it replaces the daemon insecure registries with a new set of insecure registries. If some existing insecure registries in daemon’s configuration are not in newly reloaded insecure resgitries, these existing ones will be removed from daemon’s config.

registry-mirrors: it replaces the daemon registry mirrors with a new set of registry mirrors. If some existing registry mirrors in daemon’s configuration are not in newly reloaded registry mirrors, these existing ones will be removed from daemon’s config.

shutdown-timeout: it replaces the daemon’s existing configuration timeout with a new timeout for shutting down all containers.

features: it explicitly enables or disables specific features.

这篇笔记整理自我自己的实践记录,如果做法有出入,或者你踩过别的坑,欢迎到留言板一起聊聊。

站内搜索

没有找到内容!