Skip to content

fix: prevent orphaned containers when deleting compose services#4185

Merged
Siumauricio merged 1 commit intocanaryfrom
fix/compose-delete-orphaned-containers
Apr 9, 2026
Merged

fix: prevent orphaned containers when deleting compose services#4185
Siumauricio merged 1 commit intocanaryfrom
fix/compose-delete-orphaned-containers

Conversation

@Siumauricio
Copy link
Copy Markdown
Contributor

@Siumauricio Siumauricio commented Apr 9, 2026

Summary

  • Fixes composeType: "compose" deletion leaving orphaned containers and volumes running
  • Commands were chained with &&, so if the project directory was missing, cd would fail and docker compose down would never execute
  • Uses ; to run each command independently, matching the existing stack deletion pattern from PR fix: prevent orphaned docker stacks when compose directory is missing #3692

Closes #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, the cd would fail and docker compose down would never execute. The fix replaces && with ; so each command runs independently, and removes the now-unnecessary cd and cwd option since docker compose -p <project-name> down can identify containers by their project label without needing the compose file in the working directory. This aligns the behavior with the existing stack deletion 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.appName is 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

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
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 9, 2026
@Siumauricio Siumauricio merged commit f4cae5f into canary Apr 9, 2026
5 checks passed
@Siumauricio Siumauricio deleted the fix/compose-delete-orphaned-containers branch April 9, 2026 22:26
@dosubot dosubot bot added the bug Something isn't working label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete Compose service does not stop/remove containers or volumes (v0.28.8)

1 participant