1

By default docker-compose up keeps running even if some of the containers terminate and restart is set to no.

Is there a configuration to tell it to terminate (and stop all containers) when one of my containers finishes (the process in CMD terminates)?

Bonus points if it gets the exit code from the process of that container

loopbackbee
  • 21,962
  • 10
  • 62
  • 97
  • @spender Thanks, it does, even if the title wouldn't suggest so directly. I'll vote to close this as a duplicate – loopbackbee Apr 18 '20 at 18:07

1 Answers1

3

Looks like you want to supply the

--abort-on-container-exit

command line parameter to docker-compose. See https://docs.docker.com/compose/reference/up/

To get an exit code:

--exit-code-from SERVICE

will return the exit code of SERVICE, and implies --abort-on-container-exit

spender
  • 117,338
  • 33
  • 229
  • 351