-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Description
docker compose up -d waits for certain services to enter healthy state before detaching. I would expect this behavior only if --wait is set.
Steps To Reproduce
docker-compose.yml:
services:
a:
image: busybox
command: sh -c "sleep 10"
init: true
network_mode: none
healthcheck:
test: [ "CMD-SHELL", "if [ -f /healthy ]; then exit 0; else (sleep 1 & touch /healthy); exit 1; fi" ]
interval: 1s
timeout: 1s
b:
image: busybox
command: sh -c "sleep 10"
init: true
network_mode: none
healthcheck:
test: [ "CMD-SHELL", "if [ -f /healthy ]; then exit 0; else (sleep 3 & touch /healthy); exit 1; fi" ]
interval: 1s
timeout: 1s
depends_on:
a:
condition: service_healthyUnexpected: up -d waits for A to become healthy before detaching:
% time docker compose up -d
[+] Running 2/2
✔ Container up-wait-a-1 Healthy 3.7s
✔ Container up-wait-b-1 Started 3.7s
[3.86s]
Adding --wait waits for A and B (as expected):
% time docker compose up -d --wait
[+] Running 2/2
✔ Container up-wait-a-1 Healthy 4.2s
✔ Container up-wait-b-1 Healthy 8.2s
[8.35s]
Removing depends_on from compose file restores expected behavior of immediate detach or optional wait:
% time docker compose up -d
[+] Running 2/2
✔ Container up-wait-b-1 Started 0.1s
✔ Container up-wait-a-1 Started 0.1s
[0.17s]
% time docker compose up -d --wait
[+] Running 2/2
✔ Container up-wait-b-1 Healthy 1.6s
✔ Container up-wait-a-1 Healthy 1.6s
[1.68s]
Compose Version
Docker Compose version v2.35.1-desktop.1
Docker Environment
Client:
Version: 28.1.1
API version: 1.49
Go version: go1.23.8
Git commit: 4eba377
Built: Fri Apr 18 09:49:45 2025
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.41.2 (191736)
Engine:
Version: 28.1.1
API version: 1.49 (minimum version 1.24)
Go version: go1.23.8
Git commit: 01f442b
Built: Fri Apr 18 09:52:08 2025
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.7.27
GitCommit: 05044ec0a9a75232cad458027ca83437aae3f4da
runc:
Version: 1.2.5
GitCommit: v1.2.5-0-g59923ef
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Anything else?
No response