fix(up): normalize relative bind mount paths to absolute#84
Closed
Cyb3rDudu wants to merge 2 commits into
Closed
Conversation
Apple `container` rejects `./app:/app` style bind mounts because the volume-name validation regex `^[A-Za-z0-9][A-Za-z0-9_.-]*$` doesn't match strings starting with `./`, `../`, or containing `/`. The existing code computed an absolute `fullHostPath` for FileManager but still passed the original relative `source` to `container run -v`, producing "Invalid volume name './app'" at startup. Extract the source-path resolution into a static helper `resolveBindMountSource(_:cwd:)` and wire `configVolume` through it. Already-absolute and `~`-prefixed paths pass through unchanged; relative paths get joined to `cwd` and standardized via `URL.standardizedFileURL`, collapsing `./` and `../` segments. Picks up the approach from Mcrich23#42; testable static helper makes the behavior covered by unit tests rather than only verifiable via a full `compose up`. Fixes Mcrich23#4.
9 cases for resolveBindMountSource: - `./foo` → `<cwd>/foo` - bare relative `foo/bar` → `<cwd>/foo/bar` - `../foo` → `<parent>/foo` - intermediate `..` collapses (`foo/../bar` → `<cwd>/bar`) - absolute `/abs/foo` passes through unchanged - already-absolute path with `/./` is left alone (don't second-guess) - `~/foo` left literal for apple/container to expand - `.//foo` double-slash collapses - the issue Mcrich23#4 `./app` case + post-conditions for the validation regex
This was referenced May 4, 2026
Cyb3rDudu
added a commit
to Cyb3rDudu/Container-Compose
that referenced
this pull request
May 5, 2026
…t paths + tests
Contributor
Author
|
Last one — just a nudge on the bind mount normalization. There's some adjacent work in #94 (file mounts) but this PR handles the relative path case separately. Let me know if you'd prefer these combined. |
Owner
|
@Cyb3rDudu thank you for all of the PRs. I just merged #94 and it seems to have created a merge conflict. If you fix that, I would be happy to merge it in! Hoping to release 0.12.0 with all of these changes tomorrow. |
Contributor
Author
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.
Compose files using relative bind mounts fail to start:
configVolumealready computes an absolutefullHostPathfor the directory-create path, but passes the original relativesourcetocontainer run -v. The daemon then runs the value through its volume-name regex and rejects it.Pulls the source-path resolution into a static helper
resolveBindMountSource(_:cwd:)and wiresconfigVolumethrough it. Already-absolute and~-prefixed paths pass through unchanged; relative paths get joined tocwdand standardized viaURL.standardizedFileURL, collapsing./and../segments. The runtime side of the fix is the same as #42; this PR adds the unit tests Morris asked for there.Tests: 9 static cases for the helper covering
./foo, bare relative,../foo, intermediate.., absolute pass-through,~/fooliteral preservation,.//foodouble-slash, and the exact./appcase from the issue.Fixes #4. Supersedes #42 (credit to @ttys3 for the original approach).