运行完成后,docker-compose up命令返回代码始终为零 [英] docker-compose up command return code upon run completion is always ZERO
问题描述
docker-compose
运行完成时返回代码始终为零
docker-compose
return code upon run completion is always ZERO
[nlakshmi@ROSE02T44GUH03Q database]$ docker-compose up
Recreating database_database_1 ... done
Attaching to database_database_1
database_1 | + mkdir -p -m 0755 /opt/adp/logs/db_tester/rpm/installs/
database_1 | + '[' -z abcd ']'
database_1 | + /root/bin/generateDBConfigData_FromManifest.sh abcd
database_1 | /tmp/manifest_02042019_143116.txt: line 1: syntax error near unexpected token `<'
database_1 | /tmp/manifest_02042019_143116.txt: line 1: `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>Oops, can't find that - Bitbucket</title><script>'
database_1 | Starting work......
database_1 | Starting clones.....
database_1 | Let us clone the config templates for tag
database_1 | fatal: Invalid refspec '+refs/tags/:refs/tags/'
database_1 | ERROR - prrs_repository wans't informed
database_1 | + source /tmp/abcd
database_1 | /root/bin/install_db.sh: line 43: /tmp/abcd: No such file or directory
database_1 | + '[' x == x ']'
database_1 | + echo 'ERROR - prrs_repository wans'\''t informed'
database_1 | + exit 1
database_database_1 exited with code 1
[nlakshmi@ROSE02T44GUH03Q database]$ echo $?
0
我跑了 docker-compose up
并且上面粘贴的输出显示,即使容器失败,docker-compose也不会退出并显示正确的错误代码。在这种情况下,我正在从 docker-compose up
I ran docker-compose up
and the output pasted above shows that even though the container failed, docker-compose did not exit with the right error code. In this case I was expecting NON-ZERO exit code from docker-compose up
给出了什么?
推荐答案
要将容器的退出代码返回给docker-compose up命令,请传递-从SERVICE退出代码
参数到 docker-compose up
命令。
To return the exit code of the container back to the docker-compose up command, pass --exit-code-from SERVICE
argument to docker-compose up
command.
docker-compose up --exit-code-from database
$ b $退出代码b
假设您要返回数据库
服务的退出代码。
注意:这还意味着,如果停止了任何容器,则所有容器都将停止。
Note: This also implies that all containers will be stopped if any container was stopped.
参考- https://docs.docker.com/compose/reference/up/
这篇关于运行完成后,docker-compose up命令返回代码始终为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!