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

相关推荐
·薯条大王7 小时前
经济实惠玩云服务器|一台云服务器多人共用,子账号配置教程
java·linux·运维·服务器·汇编·c++·python
小小、码农10 小时前
Linux进程控制:从fork到exec,手写一个简易Shell
linux·运维·服务器
不会就选b11 小时前
Linux之进程间通信(二)---模拟进程池
linux·运维·服务器
沫璃染墨13 小时前
《从零入门Linux系统篇(十五):系统工具篇·六——GDB调试器详解:从程序执行控制到高级调试技巧》
linux·运维·服务器·c语言·c++
AIgorithmGEEK13 小时前
Linux 环境变量完全指南:从入门到理解底层原理
linux·运维·服务器
修罗王14 小时前
Linux Docker 服务管理与排查实战指南(新手速查版)
运维·docker
迪康Defender14 小时前
从静态存储到动态流转:终端透明加密两种模式实战解析
运维·服务器·网络·数据库·其他
酷可达拉斯14 小时前
Linux操作系统-升级OpenSSH修复漏洞
linux·运维·服务器·云计算
云川之下16 小时前
【k8s】NAD(NetworkAttachmentDefinition)与SR‑IOV‑Operator 关系
云原生·容器·kubernetes
张龙68716 小时前
Docker 镜像瘦身实战:从 1.2GB 到 128MB,我踩过的 7 个坑和一套可复制的方法论
运维·后端·docker