I am working with a team that uses docker-compose to start a set of helper services, but does not use docker when the code is being developed.
Here, docker-compose is just a convenient way to run the helper services while we develop the main server code.
We have a lot of custom code that tries to detect if the helper services are healthy. I would like to use the healthcheck
feature of docker-compose.
However, docker-compose does not block unless you define some service as depends_on: ... condition: service healthy
. In my case I ve done this stupid thing; I ve simply run hello-world and made it block on the other services being healthy.
helper1:
...
healthcheck:
test: ["CMD", "curl", "-f", "http://helper1:1234/ready"]
interval: 10s
timeout: 5s
retries: 5
helper2:
...
healthcheck:
test: ["CMD", "curl", "-f", "http://helper2:5678/health"]
interval: 10s
timeout: 5s
retries: 5
hello-world:
image: docker.io/library/hello-world
depends_on:
helper1:
condition: service_healthy
helper2:
condition: service_healthy
Having a dummy service seems inelegant. Is there another way to make my docker-compose
command block until everything is healthy?