Skip to content

feat(up): stamp com.docker.compose project/service labels on containers#110

Open
DonsWayo wants to merge 1 commit into
Mcrich23:mainfrom
DonsWayo:feat/compose-project-labels
Open

feat(up): stamp com.docker.compose project/service labels on containers#110
DonsWayo wants to merge 1 commit into
Mcrich23:mainfrom
DonsWayo:feat/compose-project-labels

Conversation

@DonsWayo

@DonsWayo DonsWayo commented Jun 17, 2026

Copy link
Copy Markdown

container-compose up names containers <project>-<service> but writes no labels
(container inspectlabels: {}). External tools (GUIs, dashboards, scripts) that want to
group 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/ps continue to work by name.

Diff

One file, +6 in ComposeUp.swift, right after --name is appended:

runCommandArgs.append(contentsOf: ["--label", "com.docker.compose.project=\(projectName)"])
runCommandArgs.append(contentsOf: ["--label", "com.docker.compose.service=\(serviceName)"])

Verified (macOS 26, container 1.0.0)

$ container-compose up -d --file docker-compose.yml   # name: lblproj, service: one
$ container inspect lblproj-one | jq .configuration.labels
{
  "com.docker.compose.project": "lblproj",
  "com.docker.compose.service": "one"
}
$ container-compose down --file docker-compose.yml     # tears down unchanged

Built from source and run against a real daemon; swift build clean.

Notes

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.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant