docker stop slow 解决

验证 NanoMQ stop slow 的问题

  • daemon 和非 daemon 两种方式 docker stop 都很慢

疑问是默认情况下,SIGTERM 会被处理。

  • 模拟 docker 内发送 SIGTERM 信号
bash 复制代码
# The  default  signal  for  kill is TERM
# pkill  will  send  the  specified  signal  (by  default SIGTERM) to each
# process instead of listing them on stdout.
$ kill pid 
$ pkill program

docker 内收不到信号。

查到资料显示:pid 为 1 的进程的 sigterm 默认被屏蔽了,除非手动捕获该信号。于是,在程序处理中手动捕获该信号,问题解决。

pid 1 is special on Linux, it is unkillable, meaning that signals that would normally terminate a process if it has no handler installed do not terminate it. In other words,pid 1 must handle SIGTERM explicitely for the usual scemantics to apply. I keep rediscovering this with containers...

raby.sh - SIGTERM and PID 1: Why does a container linger after receiving a SIGTERM.

这部分也有解释:

Dockerfile reference | Docker Docs

相关推荐
fuyongliang12333 分钟前
linux Nginx服务配置介绍,和配置流程
运维·服务器·网络
UNbuff_02 小时前
Linux bzip2 命令使用说明
linux·运维·服务器
IOT-Power3 小时前
Ubuntu下把 SD 卡格式化为 FAT32
linux·运维·ubuntu
m_136873 小时前
Mac Intel 芯片部署 YOLO(Docker 方式,支持离线打包与 Compose 管理)
yolo·macos·docker
潘晓可3 小时前
Nextcloud 实战:打造属于你的私有云与在线协作平台
docker
衍余未了4 小时前
centos9 docker启动不起来,docker启动发生堵塞问题!
运维·docker·容器
LJC_Superman4 小时前
Web与Nginx网站服务
运维·服务器·前端·网络·数据库·nginx·vim
proware4 小时前
昇腾310i Pro固件说明
linux·运维·服务器
烟雨书信4 小时前
安全运维和系统安全
运维·安全
我真的是大笨蛋4 小时前
K8S-基础架构
笔记·云原生·容器·kubernetes