You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a docker-compose container depends on another using depends_on and waits for service_healthy... if that dependent container exits with an error on startup then the container waiting will wait indefinitely.
I would expect the docker compose run to exit informing the user that a dependent container failed to start. Similar to what happens if the dependent container gets as far as running the health check and is found to be unhealthy then the compose command does in fact exit with an error (as I'd expect).
If this is expected behaviour, is there any better way to detect the failed container and exit the compose command?
Steps To Reproduce
The docker-compose.yml demonstrates the issue / observation. It has a test-runner container which depends on two other containers starting up healthy. The frontend starts up ok, the backend is set to exit 1 on startup.
services:
test-runner:
image: alpine:latest
command: sh -c "echo frontend came up"
depends_on:
frontend:
condition: service_healthy
backend:
condition: service_healthy
# will start up healthy
frontend:
image: nginx:latest
ports:
- 80:80
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost || exit 1"]
interval: 5s
timeout: 5s
retries: 10
start_period: 60s
# will exit with error on startup
backend:
image: nginx:latest
ports:
- 81:80
command: sh -c "exit 1" # simulate app crash on startup
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost || exit 1"]
interval: 5s
timeout: 5s
retries: 10
start_period: 60s
Run this command:
$ docker compose run test-runner
Observe that frontend starts ok, backend exits immediately and that the docker compose run does not return and blocks indefinitely.
Hiya @fgstewart, thanks for the report. I believe this was fixed in #10029, and in v2.14.2 I can't replicate your issue. I'll close the issue for now, but please comment here if you still experience it with the latest Compose version
Description
When a docker-compose container depends on another using
depends_on
and waits forservice_healthy
... if that dependent container exits with an error on startup then the container waiting will wait indefinitely.I would expect the
docker compose run
to exit informing the user that a dependent container failed to start. Similar to what happens if the dependent container gets as far as running the health check and is found to be unhealthy then the compose command does in fact exit with an error (as I'd expect).If this is expected behaviour, is there any better way to detect the failed container and exit the compose command?
Steps To Reproduce
docker-compose.yml
demonstrates the issue / observation. It has atest-runner
container which depends on two other containers starting up healthy. Thefrontend
starts up ok, thebackend
is set toexit 1
on startup.frontend
starts ok,backend
exits immediately and that thedocker compose run
does not return and blocks indefinitely.Compose Version
Docker Environment
Anything else?
No response
The text was updated successfully, but these errors were encountered: