Repository navigation
Add -p/--project-name and docker compose project name resolution - #187
Merged
Merged
Conversation
… name resolution
Resolve the project name with the same precedence as docker compose:
-p/--project-name flag > COMPOSE_PROJECT_NAME (process env > .env) >
top-level 'name' field (now with ${VAR:-default} interpolation) >
directory name.
Previously a name like ${COMPOSE_PROJECT_NAME:-myproj} was used
literally, producing invalid container names. ComposeDown also gains
.env file loading so 'down' resolves the same names as 'up'.
adrum
force-pushed
the
feat/compose-project-flags
branch
from
November 14, 2026 19:59
6e1240f to
44bd95b
Compare
The fallback name came from the process cwd, so up -f <path> and down -f <path> run from different directories derived different project names and could not find each other's containers. Derive from the first compose file's directory instead — stable no matter where the command runs from, and identical to the old behavior when the file is discovered in the cwd. Covered by a unit test pinning that two different --cwd values with the same -f resolve the same name, and verified live: up from /tmp, down from $HOME, same -f, same containers.
This was referenced 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.
This is #104 ported onto current main — the commit is @w1zdun's, authorship preserved. That PR predates the shared resolution layer (#138), so it patched
up,down, andbuildindividually and has been conflict-bound ever since; after #138 the whole feature lands in one place,ComposeProjectOptions.projectName(for:), and every command gets it through the shared options.What it does: resolves the project name with docker compose's precedence — the
-p/--project-nameflag, thenCOMPOSE_PROJECT_NAME(process environment over the.envfile), then the composename:field with${VAR:-default}interpolation, then the directory name.It also fixes the bug from the original report: a
name:like${COMPOSE_PROJECT_NAME:-myproj}was previously used literally, producing invalid container names.w1zdun's test suite came along with the port: nine cases covering each precedence tier, the env-file vs process-env ordering, and the interpolation paths. Verified live:
-pwins overname:,COMPOSE_PROJECT_NAMEwins over the file, and an interpolatedname:resolves before containers are named.