Docker Compose Tip #51: docker compose up --wait for scripting and CI

docker compose up -d starts services in the background, but it returns immediately — before services are actually ready. --wait solves this by blocking until all services are healthy. The problem Without --wait, you often end up with fragile sleep-based scripts: # Fragile: how long is enough? docker compose up -d sleep 10 npm test The solution docker compose up --wait npm test --wait starts services in detached mode and blocks until every service with a healthcheck reports healthy. If a service fails to become healthy, the command exits with a non-zero status. ...

April 10, 2026 · 2 min · 354 words · Guillaume Lours