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

相关推荐
高峰君主5 分钟前
全栈自动化:从零构建智能CI/CD流水线
运维·ci/cd·自动化
IT运维爱好者33 分钟前
Ubuntu 22.04.4操作系统初始化详细配置
linux·运维·服务器·ubuntu
qq_543248521 小时前
正则表达式三剑客之——grep和sed
linux·运维·正则表达式
极小狐2 小时前
极狐GitLab 的合并请求部件能干什么?
运维·git·安全·gitlab·极狐gitlab
H1346948902 小时前
服务器异地备份,服务器异地备份有哪些方法?
运维·服务器
ImAlex2 小时前
运维大师教你使用流量监控神器nethogs分析Linux进程网络流量
linux·运维
ImAlex2 小时前
运维大神教你如何用iftop和ss命令结合排查带宽占用高的进程
linux·运维
Lonwayne2 小时前
Web服务器技术选型指南:主流方案、核心对比与策略选择
运维·服务器·前端·程序那些事
法迪2 小时前
Linux电源管理(2)_常规的电源管理的基本概念和软件架构
linux·运维·服务器·功耗
古德赖可可3 小时前
chrony服务器(2)
linux·运维·服务器