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 分钟前
容器:软件世界的标准集装箱
linux·运维·c++·docker·容器
zxsz_com_cn42 分钟前
设备健康管理大数据平台:工业智能化的核心数据引擎
运维·人工智能
呉師傅1 小时前
关于联想ThinkCentre M950t-N000 M大师电脑恢复预装系统镜像遇到的一点问题
运维·网络·windows·电脑
阑梦清川2 小时前
docker入门教程--部署nginx和tomcat
nginx·docker·tomcat
三坛海会大神5552 小时前
k8s(十)Helm详解
云原生·容器·kubernetes
安卓开发者2 小时前
Docker命令大全:从入门到精通
docker·容器·eureka
K_i1343 小时前
Kubernetes流量管理:从Ingress到GatewayAPI演进
云原生·容器·kubernetes
王廷胡_白嫖帝3 小时前
1. Linux 驱动开发前景
linux·运维·驱动开发
wangbing11253 小时前
迁移服务器
运维·服务器
细节控菜鸡3 小时前
【排查实录】Web 页面能打开,服务器能通接口,客户端却访问失败?原因全在这!
运维·服务器·前端