fix: ignore one-off container exit events in monitor - #14021
Conversation
Add oneOffFilter(false) to the Events subscription in monitor.Start() to exclude one-off containers created by `docker compose run` from triggering abort-on-container-exit. The initial container list (ContainerList) already excludes one-offs, but the event subscription didn't, causing one-off containers that exit to tear down the entire compose project. Fixes docker#14020
|
Thanks for the fast turnaround. I'm the reporter — built this branch (cross-compiled darwin/arm64, tested against Engine 29.4.0 on macOS) and ran the repro from the issue plus two adjacent cases:
Confirmed fixed for me. Worth adding a regression test in |
|
LGTM, but please signoff your commit (this is a legal requirement) |
|
Hi @ndeloof |
|
Closing in favor of #14038, which carries this exact same one-liner (credit to @waterWang for identifying the fix) plus a regression test and a signed-off commit. The DCO sign-off is a legal requirement we cannot add on the author's behalf, and this PR can't merge without it — if you come back and amend, thanks again for the contribution! |
Pull request was closed
Description
Fixes #14020
Since 2.39.0, the new
monitor.gorefactoring introduced a regression wheredocker compose up --abort-on-container-exittears down the project when an unrelated one-off container created bydocker compose runexits.Root cause: The
ContainerListcall inmonitor.Start()correctly excludes one-off containers viaoneOffFilter(false), but the event subscription (Events()) does not. One-off containers carrycom.docker.compose.oneoff=Trueand pass through the service guard, causing the monitor to see their exit and abort the project.Fix: Add
oneOffFilter(false)to theEvents()filter args, matching theContainerListfilter. This is consistent withdocker/compose-cli#1987which established this exclusion deliberately.Verification
docker compose up --abort-on-container-exit main+docker compose run --rm main trueno longer triggers premature abortdocker compose up --abort-on-container-exitstill aborts when a declared service exits (verified independent of this fix)Related
docker compose runbrings down the cluster after one-off container finishes execution. docker-archive/compose-cli#1955, ignore one-off container events docker-archive/compose-cli#1987 (same fix for the old codebase)