Compose: Docker-compose --exit-code-from is ignored

Created on 23 Apr 2018  路  1Comment  路  Source: docker/compose

Anybody can comment on my question here?

https://stackoverflow.com/questions/49973247/docker-compose-exit-code-from-is-ignored

Supposed I have multiple containers deployed

  1. init
  2. service1
  3. service2
  4. db
  5. web
  6. test

The init container runs into completion and then shutdowns by itself. That is his job, which is to do some pre-configuration stuffs then exit.

When running locally, I dont have any issues running this in my desktop work environment.

My issue is when it is deployed in my CI pipeline. When my init container finished up...it shutdowns the whole docker-compose network. Even if I explicitly set the --exit-code-from into my test container.

docker-compose up --exit-code-from test
The end result is that I am not able to run my test cases to its completion because everything is being shutdown by the init container that exits. Anybody has hints what can I do?

kinquestion

>All comments

This is working as intended, as per https://docs.docker.com/compose/reference/up/

    --abort-on-container-exit  Stops all containers if any container was
                               stopped. Incompatible with -d.
...
    --exit-code-from SERVICE   Return the exit code of the selected service
                               container. Implies --abort-on-container-exit.

You can circumvent that by running docker-compose up init && docker-compose up --exit-code-from test test (assuming the test service will start its dependencies).

Was this page helpful?
0 / 5 - 0 ratings