condition form of depends_on in docker-compose version 3
2021-03-05
Categories: DevOps
As version 3 no longer supports the condition form of depends_on, what is the alternative way to wait for a container to be started completely?
From 1.27.0, 2.x and 3.x are merged with COMPOSE_SPEC schema.
version is now optional. So, you can just remove it and specify a condition as before:
services:
web:
build: .
depends_on:
redis:
condition: service_healthy
redis:
image: redis
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 1s
timeout: 3s
retries: 30
Tags: docker-compose healthcheck docker
Related Posts:
- Docker Compose healthcheck
- Docker rootless keeps restarting?
- Let's Encrypt too many certificates already issued
- plugins/docker failed to resolve Keycloak hostname?
- Why my golang docker container exits immediately (code 127)?
Quan Tong