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

相关推荐
开开心心_Every3 小时前
文字转语音无字数限,对接微软接口比付费爽
运维·服务器·人工智能·edge·pdf·paddle·segmentfault
龙卷风卷云3 小时前
【BUG】Nginx使用upstream后端接口报 400
运维·nginx·bug
书到用时方恨少!3 小时前
Linux 常用指令使用指南:从入门到“救命”
linux·运维·服务器
说实话起个名字真难啊3 小时前
Docker 入门之网络基础
网络·docker·php
wwj888wwj3 小时前
Ansible基础(复习2)
linux·运维·服务器·ansible
ꪶꪜ4453 小时前
vlan综合实验
linux·运维·网络
咋吃都不胖lyh3 小时前
opencode在Ubuntu下无法复制
linux·运维·ubuntu
❀͜͡傀儡师3 小时前
使用 Docker 部署 Neko 自托管虚拟浏览器(Firefox)
docker·容器·firefox
Java面试题总结4 小时前
Nginx 配置笔记
运维·笔记·nginx
亚空间仓鼠4 小时前
OpenEuler系统常用服务(八)
linux·运维·服务器·网络