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

相关推荐
小晶晶京京13 分钟前
day34-LNMP详解
linux·运维·服务器
fengyehongWorld1 小时前
Linux crontab定时任务
linux·运维
碎像1 小时前
Linux上配置环境变量
linux·运维·服务器
40kuai2 小时前
kubernetes中数据存储etcd
容器·kubernetes·etcd
敲上瘾2 小时前
Linux系统cgroups资源精细化控制基础
linux·测试工具·docker·压力测试·cgroups
sunflower_w3 小时前
linux I2C核心、总线与设备驱动
linux·运维·服务器
myzzb3 小时前
基于uiautomation的自动化流程RPA开源开发演示
运维·python·学习·算法·自动化·rpa
Harvey_D3 小时前
【部署K8S集群】 1、安装前环境准备配置
云原生·容器·kubernetes
伊成4 小时前
Docker 部署 Nginx 完整指南
nginx·docker·容器
网硕互联的小客服5 小时前
Apache 如何支持SHTML(SSI)的配置方法
运维·服务器·网络·windows·php