加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-16 03:22:31 所属栏目:安全 来源:网络整理
导读:我正在监督下在Docker中构建一个tomcat容器.如果Dockerfile中的默认命令是 CMD supervisord -c /etc/supervisord.conf 当我调度docker stop命令时,容器成功退出,退出代码为0. 但是如果我有 CMD ["/run"] 在run.sh中 supervisord -c /etc/supervisord.conf do

我正在监督下在Docker中构建一个tomcat容器.如果Dockerfile中的默认命令是

CMD supervisord -c /etc/supervisord.conf

当我调度docker stop命令时,容器成功退出,退出代码为0.

但是如果我有

CMD ["/run"] 

在run.sh中

supervisord -c /etc/supervisord.conf

docker stop命令为我提供退出代码-1.在查看日志时,主管似乎没有收到指示退出请求的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)

任何帮助表示赞赏.

谢谢,
卡尔提克

更新:

administratord.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运行该进程时,信号仅发送到该进程.除非你是

>尽力向子进程发送信号,例如带陷阱
>将信号发送到过程组.
>在exec.sh中执行exec主管…

子进程将无法获得信号.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读