Docker 容器的 kill stop rm之间和run start之间的区别

本文详细解释了Docker中stop与kill命令的区别:stop先发送SIGTERM信号允许容器优雅关闭,再发送SIGKILL强制终止;kill直接发送SIGKILL信号强制终止容器。此外还介绍了docker rm命令用于删除容器。

The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL. The first signal can be changed with the STOPSIGNAL instruction in the container’s Dockerfile, or the --stop-signal option to docker run.

The docker kill subcommand kills one or more containers. The main process inside the container is sent SIGKILL signal (default), or the signal that is specified with the --signal option. You can reference a container by its ID, ID-prefix, or name. 

以上是官方分别对 stop 和 kill 的解释,可以发现 stop 在发送 SIGKILL 信号杀死容器进程之前会发送一个 SIGTERM 信号提醒容器进程即将被结束,以供容器有时间进行退出准备工作(优雅退出)

而 kill(不加 --signal)会直接向容器进程发送 SIGKILL 信号,直接终止进程


不管是 stop 还是 kill 都能通过 docker start 重新启动(不会重新分配容器ID)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值