I have my docker-compose.yml like:
version: '3.9'
services:
app:
image: whatever:latest
ports:
- "8081:8080"
healthcheck:
test: "curl -s http://localhost:8080/q/health | grep -q '\"status\": \"UP\"'"
interval: 5s
timeout: 5s
retries: 20
app-monitor:
image: whatever:latest
depends_on:
app:
condition: service_healthy
This works very well on docker-compose up -d . But there's a problem, steps to reproduce:
docker-compose up -ddocker-compose stop appdocker-compose start app-monitor(Starting app-monitor ... done)
Shoudn't step 3 fail?
How do I make service app-monitor to fail if the depends_on target service is down?
My purpose here is to make sure all docker-compose services are up and running at all times, in bash would look like:
if ! docker-compose start app-monitor &> /dev/null; then
docker-compose down && docker-compose up -d
fi