Using docker-compose with CI - how to deal with exit codes and daemonized linked containers?

后端 未结 9 1235
故里飘歌
故里飘歌 2020-12-07 11:45

Right now our Jenkins agents generate a docker-compose.yml for each of our Rails projects and then run docker-compose up. The docker-compose.yml has a main \"web\" container

9条回答
  •  -上瘾入骨i
    2020-12-07 11:59

    Building on kojiro's answer:

    docker-compose ps -q | xargs docker inspect -f '{{ .State.ExitCode }}' | grep -v '^0' | wc -l | tr -d ' '

    1. get container IDs
    2. get last runs exit code for each container ID
    3. only status codes that does not start with '0'
    4. count number of non-0 status codes
    5. trim out white space

    Returns how many non-0 exit codes were returned. Would be 0 if everything exited with code 0.

提交回复
热议问题