fix: prevent orphaned containers when deleting compose services#4185
Merged
Siumauricio merged 1 commit intocanaryfrom Apr 9, 2026
Merged
fix: prevent orphaned containers when deleting compose services#4185Siumauricio merged 1 commit intocanaryfrom
Siumauricio merged 1 commit intocanaryfrom
Conversation
Commands were chained with && so if the project directory was missing, cd would fail and docker compose down would never execute — leaving containers and volumes running. Use semicolons to run each command independently, matching the existing stack deletion pattern. Closes #4064
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
composeType: "compose"deletion leaving orphaned containers and volumes running&&, so if the project directory was missing,cdwould fail anddocker compose downwould never execute;to run each command independently, matching the existingstackdeletion pattern from PR fix: prevent orphaned docker stacks when compose directory is missing #3692Closes #4064
Greptile Summary
This PR fixes orphaned containers left behind when deleting compose services (
composeType: "compose"). The root cause was that commands were chained with&&, so if the project directory didn't exist, thecdwould fail anddocker compose downwould never execute. The fix replaces&&with;so each command runs independently, and removes the now-unnecessarycdandcwdoption sincedocker compose -p <project-name> downcan identify containers by their project label without needing the compose file in the working directory. This aligns the behavior with the existingstackdeletion pattern introduced in PR #3692.Confidence Score: 5/5
Safe to merge — the fix is minimal, correct, and mirrors the established pattern for stack-type deletion.
The change is a targeted fix: replacing && with ; ensures docker compose -p down always runs even when the project directory is absent. docker compose -p down correctly identifies containers via project labels without a compose file. rm -rf with the -f flag silently succeeds on non-existent paths, so there are no new error surface areas. All findings are P2 or better.
No files require special attention.
Vulnerabilities
No security concerns introduced by this PR. Note that
compose.appNameis interpolated directly into shell commands, but this is a pre-existing pattern unchanged by this diff.Reviews (1): Last reviewed commit: "fix: prevent orphaned containers when de..." | Re-trigger Greptile