Repository navigation
Use the Mount API for mounts whose target contains a colon - #14423
Huang-404-Q wants to merge 1 commit into
Conversation
…ress The legacy Bind-API form "source:target[:options]" is split on colons by the engine, so a bind source or a mount target containing a colon - a named volume mounted at /foo/bar:baz, for instance - was sent verbatim and rejected as an invalid volume specification. Detect that case and fall back to the Mount API, which carries the paths as fields. Windows drive-letter paths keep the string form: their colon is not a separator, and switching them would change bind mountpoint creation for no reason. Signed-off-by: huang <13165998033@163.com>
|
I'd prefer we introduce an explicit option to opt-in for the |
|
Fair — and thanks for pointing at compose-go#979. Worth noting what the current state is: the Mount API is already reachable today, just not explicitly — any advanced option on the entry forces it ( Given that, I see three ways forward and I'm happy to do whichever you prefer:
My preference is 3 if #979 is likely to land in this cycle, otherwise 1 as a cheap interim, since it doesn't commit the project to a new field. Let me know and I'll rework or close. |
Fixes #12993.
A long-syntax volume whose target contains a colon fails to create, because Compose sends it as a legacy bind string and the engine splits that on colons:
A colon is a legal filename character on Linux. This makes such mounts fall back to the
MountsAPI, which carries source and target as separate fields. Windows drive letters (C:\data) are not treated as separators and keep using the bind string.Details
Why
Compose prefers
HostConfig.Bindswhen a mount is simple enough and usesMountsotherwise. The "simple enough" checks only looked at mount options (bindRequiresMountAPI/volumeRequiresMountAPI), but the engine splits a bind string on colons (source:target:options), so a colon in the source or the target is read as a field separator no matter what the options are.Change
with
Tests
Three cases added to
Test_buildContainerVolumes: a named volume and a bind mount with a colon in the target (both must produceMountsand no bind string), plus a Windows target (C:\data) that must still producemy_volume:C:\data:rw.The
pkg/composetest package does not build on Windows (start_test.gois//go:build !windowswhile other test files use its helpers), so the binary was cross-compiled and run under Linux:Without the change:
With it:
AI usage: the change and this description were drafted with Claude Code and then reviewed, built and tested by me; the analysis above is checked against the engine's mount parser and the tests were run as shown.