docker-compose up command return code upon run completion is always ZERO

[亡魂溺海] 提交于 2020-05-15 05:19:19

问题


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&#39;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

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

What gives ?


回答1:


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

Assuming you want the exit code from the database service to be returned.

Note: This also implies that all containers will be stopped if any container was stopped.

Reference - https://docs.docker.com/compose/reference/up/



来源:https://stackoverflow.com/questions/54524198/docker-compose-up-command-return-code-upon-run-completion-is-always-zero

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!