Repository navigation
Never stop or remove another project's container on a name collision - #181
Merged
Merged
Conversation
Mcrich23
requested changes
Nov 24, 2026
Mcrich23
left a comment
Owner
There was a problem hiding this comment.
lgtm! Just please cleanup/deslop the comments.
…me collision up's pre-start cleanup and down's stop loop find containers by candidate names, and candidate names can collide across projects: project demo + service web-x produce demo-web-x, which is also the name project demo-web gives its service x. up would silently stop and delete the other project's container before creating its own. Labels are now authoritative: a container whose com.docker.compose.project label names a different project is left alone with a warning (creation then fails with a name conflict, matching docker's behavior, instead of destroying foreign state). Unlabeled pre-Mcrich23#126 containers keep the name-based behavior — a name match is the only identity they have. Same rule ps applies to its listing fallback; shared as ComposeProject.ownsContainer with unit coverage for the foreign, matching, and unlabeled cases.
adrum
force-pushed
the
feat/label-scoped-cleanup
branch
from
November 25, 2026 14:35
109dfb4 to
b4a62c6
Compare
Contributor
Author
|
@Mcrich23 we should be good now! |
Mcrich23
approved these changes
Nov 25, 2026
1 task
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.
Container names can collide across projects. Project demo with a service web-x expects its container at demo-web-x — but that's also the name project demo-web gives its service x. When that happens today, up's pre-start cleanup finds the other project's container by name and silently stops and deletes it. down stops it.
This applies the same rule #172 established for lookups to the two write paths: labels are authoritative. A container whose com.docker.compose.project label names a different project is left alone with a warning. If the current run then genuinely needs that name, creation fails with a name conflict — same as docker compose, which never removes another project's container. Unlabeled containers from before the labels existed keep the name-based behavior, since a name match is the only identity they have.
Reproduced live: with demo-web's container running, up for project demo used to delete it. Now it warns (not touching container 'demo-web-x' — its labels identify it as project 'demo-web') and the container survives. The ownership rule itself merged with #172 and is already covered there; this PR is just the two guards that use it.