opts: MountOpt: relax client-side validation of mount target#6771
Merged
vvoland merged 1 commit intodocker:masterfrom Feb 2, 2026
Merged
opts: MountOpt: relax client-side validation of mount target#6771vvoland merged 1 commit intodocker:masterfrom
vvoland merged 1 commit intodocker:masterfrom
Conversation
The daemon already validates the target, so we don't have to validate
if a target is set. Instead, we can ignore empty targets, but produce
an error if a target option was set, but set to an empty value.
With this patch applied, omitting a target option is ignored by the CLI,
but still invalidated by the daemon if the given mount-type requires a
mount target;
docker run --rm --mount type=bind,src=/var/run/docker.sock alpine
docker: Error response from daemon: invalid mount config for type "bind": field Target must not be empty
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst=../foo alpine
docker: Error response from daemon: invalid mount config for type "bind": invalid mount path: '../foo' mount path must be absolute
When passing a target option (`target`, `dst`, or `destination`), the
CLI produces an error if the value is empty;
docker run --rm --mount type=bind,src=/var/run/docker.sock,dst= alpine
invalid argument "type=bind,src=/var/run/docker.sock,dst=" for "--mount" flag: invalid value for 'dst': mount target must be a non-empty value
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Member
Author
|
Couple more changes remaining in a branch I was working on, but most of those are more "nice to have", and some refactoring (which I still may be continuing on). I'll open PR(s) for those later. @vvoland |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
vvoland
approved these changes
Feb 2, 2026
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.
The daemon already validates the target, so we don't have to validate if a target is set. Instead, we can ignore empty targets, but produce an error if a target option was set, but set to an empty value.
With this patch applied, omitting a target option is ignored by the CLI, but still invalidated by the daemon if the given mount-type requires a mount target;
When passing a target option (
target,dst, ordestination), the CLI produces an error if the value is empty;- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)