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

相关推荐
wdfk_prog30 分钟前
[Linux]学习笔记系列 -- lib/sort.c 通用的排序库(Generic Sorting Library) 为内核提供标准的、高效的排序功能
linux·运维·c语言·笔记·stm32·学习·bug
jump_jump35 分钟前
前端部署工具 PinMe
运维·前端·开源
それども2 小时前
本地怎么远程调试服务器
运维·服务器
Lin_Aries_04212 小时前
容器化 Flask 应用程序
linux·后端·python·docker·容器·flask
斯普信专业组4 小时前
Filebeat写ElasticSearch故障排查思路(上)
运维·elasticsearch·中间件·filebeat
Lin_Aries_04214 小时前
通过配置 GitLab 自动触发项目自动化构建与部署
运维·docker·容器·自动化·云计算·gitlab
zybsjn4 小时前
【实战】理解服务器流量监控中的“上行”和“下行”
运维·服务器
尘埃不入你眼眸4 小时前
Docker操作命令
运维·docker·容器
龙茶清欢5 小时前
2、Nginx 与 Spring Cloud Gateway 详细对比:定位、场景与分工
java·运维·spring boot·nginx·spring cloud·gateway
云动雨颤5 小时前
Linux运维必备:3个内存问题排查命令
linux·运维