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

相关推荐
IT成长日记1 小时前
【自动化运维神器Ansible】Ansible常用模块之File模块详解
运维·自动化·ansible·file·常用模块
獭.獭.1 小时前
Linux -- 文件【上】
linux·运维·服务器·进程·pcb
不会敲代码的XW2 小时前
高可用集群KEEPALIVED的详细部署
运维·云原生
老实巴交的麻匪2 小时前
提问的智慧,用最少的时间获得最有效的帮助
运维·团队管理
nbsaas-boot3 小时前
收银系统优惠功能架构:可扩展设计指南(含可扩展性思路与落地细节)
java·大数据·运维
爱喝酸奶的桃酥3 小时前
解密负载均衡:如何轻松提升业务性能
运维·负载均衡
搬码临时工3 小时前
使用FRP搭建内网穿透工具,自己公网服务器独享内外网端口转发
运维·服务器
longxibo3 小时前
飞牛系统安装DataEase自定义Docker包
运维·docker·容器
先生沉默先3 小时前
Docker常用命令详解:以Nginx为例
nginx·docker
ん贤4 小时前
GMP模型
运维·服务器·后端·golang