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

相关推荐
RLG_星辰28 分钟前
SHELL练习题(1-11题)记录(牛客)
linux·运维·服务器·shell
ZHOU_WUYI42 分钟前
使用Docker部署React应用与Nginx
nginx·react.js·docker
ICT系统集成阿祥4 小时前
负载均衡—会话保持技术详解
运维·负载均衡
付出不多4 小时前
linux——mysql高可用
linux·运维·mysql
L汐8 小时前
07 负载均衡
运维·nginx·负载均衡
pjx9878 小时前
服务间的“握手”:OpenFeign声明式调用与客户端负载均衡
java·运维·spring·负载均衡
牛奔8 小时前
Docker配置远程连接
运维·docker·云原生·容器·eureka
VR最前沿9 小时前
构建集成差异化灵巧手和先进机器人控制技术的自动化系统
运维·机器人·自动化
蟑螂恶霸9 小时前
解决ubuntu20中tracker占用过多cpu,引起的风扇狂转
linux·运维·ubuntu
my_styles10 小时前
docker-compose部署项目(springboot服务)以及基础环境(mysql、redis等)ruoyi-ry
spring boot·redis·后端·mysql·spring cloud·docker·容器