Search code examples
dockerdocker-composejestjssequelize-cli

Ignore container exit when using docker-compose


I am setting up a test infrastructure using docker-compose. I want to use the docker-compose option --exit-code-from to return the exit code from the container that is running tests. However, I also have a container that runs migrations on my database container using the sequelize cli. This migrations container exits with code 0 when migrations are complete and then my tests run. This causes an issue with both the --exit-code-from and --abort-on-container-exit options. Is there a way to ignore when the migration container exits?


Solution

  • --exit-code-from implies --abort-on-container-exit, which according to documentation

    --abort-on-container-exit Stops all containers if any container was stopped.

    But you could try:

    docker inspect <container ID> --format='{{.State.ExitCode}}'
    

    You can get a list of all (including stopped) containers with

    docker container ls -a
    

    Here's a nice example: Checking the Exit Code of Stopped Containers