Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure essential services - kill all services when essential services exit #11985

Open
nottrobin opened this issue Jul 16, 2024 · 0 comments

Comments

@nottrobin
Copy link

nottrobin commented Jul 16, 2024

TL;DR

A way of configuring docker compose, such that when a user of my project runs a straightforward docker compose up (with no extra options), all services will be killed if the primary one fails or dies.

Detail

When I'm using docker compose, I'm always configuring one primary service and a bunch of satellite services. E.g., I'll have an essential primary web application, with one or more databases or observability tools that it hooks into. I don't know if this describes everyone's usage, but I suspect it's the clear majority.

In this scenario, if the essential application service fails to start, all the satellite services are pointless. So it seems quite weird to me for the default experience to be that docker compose up would fail to start the only thing that really matters, but carry on and show you output from all those pointless satellites as if everything was fine.

I know I can use docker compose up --exit-code-from primary_app, but the locus of control here is wrong. It's not the user of docker compose who should be making this decision, it's the author of the compose.yml who should specify which is the essential application that has to start successfully.

Please provide a way of configuring docker compose, such that when a user of my project runs a straightforward docker compose up, all services will be killed if the essential ones fail or die.

Basically, the functionality of docker compose up --exit-code-from (see docs), but defined from within the project repo.

Possible implementations

  • essential: true: An option for any number of services to say that if they die, everything has to die. It seems reasonable to assume you might want more than one essential service

  • COMPOSE_UP_EXIT_CODE_FROM=primary_app in ./.env: If there was a way to set docker compose CLI options by adding environment variables to a local .env file, that would also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants