docker-compose
在运行完成时返回的代码始终为零
[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
什么给了?
答案 0 :(得分:0)
要将容器的退出代码返回给docker-compose up命令,请将--exit-code-from SERVICE
参数传递给docker-compose up
命令。
docker-compose up --exit-code-from database
假设您希望返回database
服务的退出代码。
注意:这还意味着,如果停止了任何容器,则所有容器将被停止。