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

相关推荐
optimistic_chen6 分钟前
【Vue3入门】自定义指令与插槽详解
linux·运维·服务器·vue.js·前端框架·指令
牛奶咖啡1315 分钟前
基于Cobbler的系统自动化安装部署——Cobbler的安装部署实践
linux·运维·服务器·cobbler·cobbler的安装配置·cobbler环境检查问题解决·cobbler中导入系统镜像
mounter62517 分钟前
深度解析 RDMA 技术的里程碑:基于 DMA-BUF 的 P2P 直接访问(GPU Direct RDMA 新姿势)
linux·运维·服务器·网络·p2p·kernel
南山十一少25 分钟前
docker的安装及使用
运维·docker·容器
无籽西瓜a29 分钟前
Docker 环境下 Redis Lua 脚本部署与执行
redis·docker·lua
Willliam_william33 分钟前
CentOS 7系统中进行时间/时区设置
linux·运维·centos
李白的天不白34 分钟前
linux安装MongoDB
linux·运维·服务器
BioRunYiXue38 分钟前
从现象到机制:蛋白降解调控研究的系统策略与实验设计
java·linux·运维·服务器·网络·人工智能·eclipse
supersolon42 分钟前
OpenClaw安装碰到的一些问题和解决方法
linux·运维·ai·openclaw·龙虾
道清茗1 小时前
【Kubernetes知识点问答题】PriorityClass、HPA、Argo CD 与 CI/CD 流水线
ci/cd·容器·kubernetes