-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
Description
Steps To Reproduce
docker-compose.yml:
services:
long-running:
image: debian:bookworm-slim
command: bash -c "sleep 20; exit 1"
short-running:
image: debian:bookworm-slim
command: bash -c "sleep 5; exit 0"
In this example, the long-running service should never return an exit code of 0. Either it completes and returns an exit code of 1, or it is interrupted in which case it should return an exit code to indicate that it was interrupted.
However, when using --exit-code-from long-running an exit code of 0 is returned:
jez@mac % docker compose up --exit-code-from long-running
[+] Running 3/3
✔ Network dockercomposetest_default Created 0.0s
✔ Container dockercomposetest-long-running-1 Created 0.1s
✔ Container dockercomposetest-short-running-1 Created 0.1s
Attaching to long-running-1, short-running-1
short-running-1 exited with code 0
Aborting on container exit...
[+] Stopping 2/2
✔ Container dockercomposetest-short-running-1 Stopped 0.0s
✔ Container dockercomposetest-long-running-1 Stopped 10.3s
jez@mac % echo $?
0
Expected outcome
docker compose up --exit-code-from long-running should return a non-zero exit code because long-running was interrupted and did not complete successfully.
Observed outcome
docker compose up --exit-code-from long-running returned an error code of 0.
Why this matters
When using docker-compose up to run integration tests in CI, it is crucial that --exit-code-from does what it says, otherwise a test may produce a false positive result.
Compose Version
Docker Compose version v2.24.6-desktop.1
Docker Environment
Client:
Version: 25.0.3
Context: desktop-linux
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: /Users/jez/.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.6-desktop.1
Path: /Users/jez/.docker/cli-plugins/docker-compose
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.24
Path: /Users/jez/.docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /Users/jez/.docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.22
Path: /Users/jez/.docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: /Users/jez/.docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.1
Path: /Users/jez/.docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /Users/jez/.docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.5.0
Path: /Users/jez/.docker/cli-plugins/docker-scout
WARNING: Plugin "/Users/jez/.docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /Users/jez/.docker/cli-plugins/docker-scan: no such file or directory
Server:
Containers: 51
Running: 13
Paused: 0
Stopped: 38
Images: 202
Server Version: 25.0.3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
cgroupns
Kernel Version: 6.6.16-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 8
Total Memory: 10.69GiB
Name: docker-desktop
ID: e67b9764-ab02-4159-b3e4-d8a67f5c18df
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false
WARNING: daemon is not using the default seccomp profile
Anything else?
No response
Reactions are currently unavailable