Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Supposed I have multiple containers deployed

  • init
  • service1
  • service2
  • db
  • web
  • 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?

like image 848
Mark Estrada Avatar asked Sep 18 '25 19:09

Mark Estrada


1 Answers

This is interesting. Is it possible to include the compose file? Maybe you have a depends_on defined, and the version of docker used by your CI pipeline handles it differently from the one on your dev environment.

At any rate, you'd want to stop using --exit-code-from, it apparently implies --abort-on-container-exit.

From 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.
like image 140
Timir Avatar answered Sep 20 '25 12:09

Timir