feat(up): stamp com.docker.compose project/service labels on containers#110
Merged
Merged
Conversation
Containers created by `up` carry no labels, so tools that want to group a stack must guess from the `<project>-<service>` name prefix — which mis-groups unrelated containers that merely share a prefix. Stamp the de-facto-standard Docker Compose labels at creation: com.docker.compose.project=<project> com.docker.compose.service=<service> so any tool can group reliably via `container inspect`. No behavior change otherwise; down/ps continue to work by name. Verified on macOS 26 + container 1.0.0: after `up`, `container inspect <project>-<service>` shows both labels; `down` tears the stack down unchanged.
This was referenced Jun 17, 2026
DonsWayo
added a commit
to DonsWayo/consai
that referenced
this pull request
Jun 17, 2026
) Adds label-based grouping as step 0 of assembly (always on, no guessing): containers carrying com.docker.compose.project group into a .composeLabeled stack regardless of the name-prefix setting. This is reliable (no false 'qa' stack, #12) and groups externally- launched stacks once the compose tool labels them (upstream Mcrich23/Container-Compose#110). - StackOrigin.composeLabeled (trusted; no 'wild' badge; link a compose file to enable up/down) - ProjectRegistry.composeProjectLabel constant + label grouping before known/inferred - StackSection offers 'Link compose file' for any unlinked stack - Test: label grouping works with inference off; unlabeled containers stay standalone - Verified live: a patched-container-compose 'shop' stack groups with no 'wild' badge Closes #14
Generalize the com.docker.compose.* label stamping introduced in this PR: - Model Service.labels: [String: String]? (property, CodingKeys, decoder, memberwise init), matching the existing Network/Volume pattern, so the Compose `labels:` directive on a service is no longer silently ignored. - In configService, pass user labels through as `--label key=value`, then stamp com.docker.compose.project/service on top so they take precedence over any user value for the same key. Keys are emitted sorted for a deterministic `container run` argv. Add a dynamic test (testUpStampsComposeLabels) plus dockerComposeYaml10 that asserts the compose labels are stamped, user labels pass through, and the stamped service label overrides a colliding user-defined value. swift build + swift build --build-tests both clean.
2682ea4 to
ebefa65
Compare
Cyb3rDudu
approved these changes
Jun 23, 2026
Cyb3rDudu
left a comment
Collaborator
There was a problem hiding this comment.
Looks good - correct mechanism, right label namespace for tool interop, and verified working. We can add a dynamic test (up → assert both labels present via inspect) so this doesn't silently regress; (2) when service.labels support lands later, make sure these two compose labels are applied last / take precedence over a user setting the same key. Nice that it composes cleanly with #104 and #113. consider folding this into the existing labels: pass-through pattern (see the commented-out network-labels block) for consistency and to also pick up user-defined service labels.
Cyb3rDudu
approved these changes
Jun 23, 2026
Cyb3rDudu
approved these changes
Jun 23, 2026
Cyb3rDudu
left a comment
Collaborator
There was a problem hiding this comment.
Looks good — generalized label stamping + test, builds clean, signed.
Cyb3rDudu
approved these changes
Jun 24, 2026
Cyb3rDudu
approved these changes
Jun 25, 2026
Cyb3rDudu
approved these changes
Jun 27, 2026
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-compose upnames containers<project>-<service>but writes no labels(
container inspect→labels: {}). External tools (GUIs, dashboards, scripts) that want togroup a stack's containers are forced to guess from the name prefix, which mis-groups
unrelated containers that merely share a prefix (e.g.
qa-web+qa-cache).This stamps the de-facto-standard Docker Compose labels on each container at creation:
com.docker.compose.project=<project>com.docker.compose.service=<service>so any tool can group a stack reliably via labels. No behavior change otherwise —
down/pscontinue to work by name.Diff
One file, +6 in
ComposeUp.swift, right after--nameis appended:Verified (macOS 26, container 1.0.0)
Built from source and run against a real daemon;
swift buildclean.Notes
projectName.com.docker.compose.*for broad tool interoperability. Happy to switchto a project-specific namespace if you'd prefer.