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

相关推荐
SkyWalking中文站9 小时前
认识 Horizon UI · 1/17:SkyWalking 新一代可观测性控制台
运维·前端·监控
雪梨酱QAQ12 小时前
Kubeneters HA Cluster部署
运维
lichenyang45316 小时前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang45316 小时前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang45316 小时前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang45316 小时前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
江华森17 小时前
Spring Cloud 微服务全栈实战:从 Eureka 到 Docker Compose 一文贯通
运维
江华森17 小时前
Matplotlib 数据绘图基础入门
运维
江华森17 小时前
NumPy 数值计算基础入门
运维
乘云数字DATABUFF5 天前
5分钟部署开源APM Databuff:OpenTelemetry全链路追踪入门实战
运维·后端