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

相关推荐
菜鸟思维17 小时前
优化NextJs 项目的Docker 镜像 从3.62G 优化到 296.85M
docker
学Linux的语莫17 小时前
linux的root目录缓存清理
linux·运维·服务器
oMcLin17 小时前
如何在 SUSE Linux Enterprise Server 15 上部署并优化 K3s 集群,提升轻量级容器化应用的资源利用率?
linux·运维·服务器
怣疯knight17 小时前
Docker Desktop 4.55.0版本安装成功教程
windows·docker
Run Out Of Brain17 小时前
解决nginx代理配置下wordpress的 /wp-admin/返回 302 重定向到登录页问题
运维·nginx
Ghost Face...17 小时前
深入解析YT6801驱动模块架构
linux·运维·服务器
线束线缆组件品替网17 小时前
Amphenol LTW 防水线缆 IP67/IP68 结构解析
运维·网络·人工智能·汽车·硬件工程·材料工程
放寒假脚后跟v18 小时前
Pod 的 YAML 文件中 exitCode 字段的具体含义、不同取值代表的场景
运维·云原生·容器·kubernetes·k8s
东方佑18 小时前
使用Docker Compose一键部署OnlyOffice:完整指南与配置解析
运维·docker·容器
原神启动118 小时前
K8S(五)—— YAML文件解析
java·容器·kubernetes