Description
docker -v short notation for volume mounts uses the HostConfig.Bind field on ContainerCreate API, and can't be fully translated into --mount flags (Volumes in ContainerCreate API) because the latter does not offer option to create missing host path on bind mount.
The --mount flag exposes many advanced options that can be used to tweak the binding, which are not available with the short -v notation. This prevents user to benefit those advanced features with the same "create if missing" behaviour.
I suggest an additional option is introduce on mount, so that user can get best of both, and tools can adopt the mount API.
Steps to reproduce the issue:
- docker run --rm --mount type=bind,src=/does_not_exists,target=/foo,non_recursive=true hello-world
- docker run --rm -v /does_not_exists:/foo hello-world
Describe the results you received:
- fails with
bind source path does not exist
- creates host path but volume is created without non_recursive flag set
Describe the results you expected:
I get an option to run 1. and get the source path created on host
or I get an option to run 2. and set the non_recursive flag
Additional information you deem important (e.g. issue happens only occasionally):
see discussion on docker-archive/compose-cli#1563 (comment) as initial reason I had to look into this :P
Output of docker version:
Additional environment details (AWS, VirtualBox, physical, etc.):
Description
docker
-vshort notation for volume mounts uses theHostConfig.Bindfield on ContainerCreate API, and can't be fully translated into--mountflags (Volumesin ContainerCreate API) because the latter does not offer option to create missing host path on bind mount.The
--mountflag exposes many advanced options that can be used to tweak the binding, which are not available with the short-vnotation. This prevents user to benefit those advanced features with the same "create if missing" behaviour.I suggest an additional option is introduce on mount, so that user can get best of both, and tools can adopt the mount API.
Steps to reproduce the issue:
Describe the results you received:
bind source path does not existDescribe the results you expected:
I get an option to run 1. and get the source path created on host
or I get an option to run 2. and set the non_recursive flag
Additional information you deem important (e.g. issue happens only occasionally):
see discussion on docker-archive/compose-cli#1563 (comment) as initial reason I had to look into this :P
Output of
docker version:Additional environment details (AWS, VirtualBox, physical, etc.):