gpt4 book ai didi

shell - 如果默认 CMD 是 shell 脚本,则 Docker 停止退出代码 -1

转载 作者:行者123 更新时间:2023-12-01 23:51:35 27 4
gpt4 key购买 nike

我正在使用 supervisord 在 Docker 中构建一个 tomcat 容器。如果 Dockerfile 中的默认命令是

CMD supervisord -c /etc/supervisord.conf

当我发送 docker stop 命令时,容器成功退出,退出代码为 0。

但是如果我有

CMD ["/run"] 

在 run.sh 中,

supervisord -c /etc/supervisord.conf

docker stop 命令给了我一个退出代码 -1。查看日志,似乎supervisord没有收到指示退出请求的SIGTERM。

2014-10-06 19:48:54,420 CRIT Supervisor running as root (no user in config file)
2014-10-06 19:48:54,450 INFO RPC interface 'supervisor' initialized
2014-10-06 19:48:54,451 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2014-10-06 19:48:54,451 INFO supervisord started with pid 6
2014-10-06 19:48:55,457 INFO spawned: 'tomcat' with pid 9
2014-10-06 19:48:56,503 INFO success: tomcat entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

与之前的日志相反,它收到一个 sigterm 并优雅地退出。

2014-10-06 20:02:59,527 CRIT Supervisor running as root (no user in config file)
2014-10-06 20:02:59,556 INFO RPC interface 'supervisor' initialized
2014-10-06 20:02:59,556 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2014-10-06 20:02:59,557 INFO supervisord started with pid 1
2014-10-06 20:03:00,561 INFO spawned: 'tomcat' with pid 9
2014-10-06 20:03:01,602 INFO success: tomcat entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2014-10-06 20:05:11,690 WARN received SIGTERM indicating exit request
2014-10-06 20:05:11,690 INFO waiting for tomcat to die
2014-10-06 20:05:12,450 INFO stopped: tomcat (exit status 143)

感谢任何帮助。

谢谢,卡尔提克

更新:

supervisord.conf文件

[supervisord]
nodaemon=true
logfile=/var/log/supervisor/supervisord.log

[program:mysql]
command=/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe --pid-file=/var/run/mysqld/mysqld.pid
stdout_logfile=/tmp/mysql.log
stderr_logfile=/tmp/mysql_err.log

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

最佳答案

当您通过 run.sh 运行进程时,信号只会发送到该进程。除非你是

  1. 不厌其烦地向子进程发送信号,例如带陷阱
  2. 向进程组发送信号。
  3. 在 run.sh 中执行 exec supervisord ...

子进程不会收到信号。

关于shell - 如果默认 CMD 是 shell 脚本,则 Docker 停止退出代码 -1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26223240/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com