Validate bind source for create_host_path false#13889
Conversation
Return an error before container creation when a bind mount explicitly disables host path creation and the resolved source path is missing. Add unit and end-to-end coverage for the create_host_path:false bind-source contract. Signed-off-by: Scarab Systems <scarab.systems@yahoo.com>
13e158f to
fbde4b9
Compare
|
Gentle follow-up on this PR. The visible checks are not showing failures on my side, and I’m happy to make adjustments if there is anything maintainers would like changed. If this is not a direction the project wants to take, I’m also happy to close it rather than leave noise in the queue. |
ndeloof
left a comment
There was a problem hiding this comment.
This won't work with a remote docker engine, and we can't offer such a feature
| } | ||
|
|
||
| func validateBindSourceExists(source string) error { | ||
| if _, err := os.Stat(source); err != nil { |
There was a problem hiding this comment.
This assumes source is LOCAL, but docker engine may be remote. There's no way to check bind source exists from compose CLI
There was a problem hiding this comment.
Thanks for the review, that makes sense. I was validating from the Compose CLI side, but I agree that this gives the wrong answer when the Docker engine is remote because the bind source is resolved on the engine host rather than necessarily on the CLI host.
I’ll close this PR rather than keep pushing a CLI-side check that can’t be correct for remote contexts. Thanks for taking a look.
What I did
Added Compose-side validation for bind mounts that set
bind.create_host_path: false.Compose now returns a missing bind source error before container creation when the resolved bind source path does not exist. This keeps the
create_host_path: falsecontract enforced without relying on daemon or Desktop path handling.I also added unit and end-to-end coverage for
docker compose run --rmwith a missing long-syntax bind source.Related issue
Related to #13602
Validation
go test ./pkg/compose -run 'TestBuildContainerVolumesReturnsErrorWhenBindSourceMissingAndCreateHostPathFalse|Test_buildContainerVolumes' -count=1go build -trimpath -tags e2e -o bin/build/docker-compose ./cmdgo test -v -count=1 ./pkg/e2e -run TestRunDoesNotCreateMissingBindSourceWhenCreateHostPathIsFalsedocker buildx bake lint