I have 3 services defined in docker-compose A
, B
and C
. B
and C
depends_on
A
. If A
's healthcheck
results in unhealthy
, I want other 2 containers not be spinned up. Currently, containers B
and C
are started only when container A
is started with healthy
status, and this is my expected behaviour. However, if container A
becomes unhealthy
after it gets created, I don't want dependent containers to be started, currently when A
is created and becomes unhealthy
only one of the other 2 container exits (sometimes A
exits and other times B
but not both). Here's the output when A
is unhealthy.
Creating A ... done
Creating C ... done
ERROR: for B Container "1339a6d12091" is unhealthy. ERROR: Encountered errors while bringing up the project.
As we can see here in the ERROR message, only for B
it shows 1339a6d12091
(container A
) is unhealthy. Whereas it should have reported this error for both B
and C
containers.
docker-compose
version: '2.3'
services:
B:
image: base_image
depends_on:
A:
condition: service_healthy
entrypoint: bash -c "/app/entrypoint_scripts/execute_B.sh"
C:
image: base_image
depends_on:
A:
condition: service_healthy
entrypoint: bash -c "/app/entrypoint_scripts/execute_C.sh"
A:
image: base_image
healthcheck:
test: ["CMD-SHELL", "test -f /tmp/compliance/executedfetcher"]
interval: 30s
timeout: 3600s
retries: 1
entrypoint: bash -c "/app/entrypoint_scripts/execute_A.sh"
My Expectation: B
and C
should wait for A
to become healthy
before starting (which is working fine for me). If A
starts and become unhealthy
without becoming healthy
even for once B
and C
should not start.