mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
## Fix: kill docker container on pipeline cancellation ### What was happening When a pipeline step was canceled (e.g. manual cancel or agent shutdown), the Docker backend would stop waiting for the container but **would not actively terminate it**. This caused containers running long-lived commands (like `sleep`, `tail -f`, servers, etc.) to continue running in the background. ## Related Issue Closes #6016 ### What this PR changes This PR ensures that **when the step context is canceled**, the running Docker container is **immediately killed**. - Listens to `ctx.Done()` in `WaitStep` - Sends a `ContainerKill` using a non-cancelable context - Preserves existing behavior for normal container exit - Prevents orphaned containers after pipeline cancellation ### Why this approach Docker containers do not automatically stop when the caller context is canceled. Explicitly killing the container on `ctx.Done()` guarantees correct cleanup and matches expected CI behavior.