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

相关推荐
斯普信专业组23 分钟前
Kafka主题运维全指南:从基础配置到故障处理
运维·分布式·kafka
倔强的石头1061 小时前
【Linux指南】用户与系统基础操作
linux·运维·服务器
云上艺旅1 小时前
centos升级内核
linux·运维·centos
kaikaile19951 小时前
centos开启samba服务
linux·运维·centos
好多知识都想学1 小时前
centos 7 部署awstats 网站访问检测
linux·运维·centos
颜淡慕潇2 小时前
【K8S系列】Kubernetes 中 Pod(Java服务)启动缓慢的深度分析与解决方案
容器·kubernetes·pod
默心2 小时前
华为云上的K8S怎么使用对象存储配置pod文件持久化。
容器·kubernetes·华为云
955.2 小时前
k8s从入门到放弃之DaemonSet控制器
云原生·容器·kubernetes
藥瓿亭2 小时前
K8S认证|CKS题库+答案| 10. Trivy 扫描镜像安全漏洞
linux·运维·服务器·云原生·容器·kubernetes·cks