Skip to content

Allow relative paths for mounting volumes to docker containers. #2524

Description

@KartikSoneji

Description
Trying to mount the current directory with -v .:/source or --mount source=.,target=/source results in an error. Using relative paths causes a new volume to be created instead of mounting the .

Steps to reproduce the issue:

  1. Run: docker run -v .:/source alpine OR docker run --mount source=.,target=/source alpine
  2. Run:
mkdir source
touch source/test
docker run -it -v ./source:/source alpine
# (in the container's shell)
ls /source

Describe the results you received:

  1. The error message:
docker: Error response from daemon: create .: volume name is too short, names should be at least two alphanumeric characters.
See 'docker run --help'.
  1. The ls command does not show any files in the /source directory. Instead, a new docker volume is created with the name source.

Describe the results you expected:

  1. The current directory to be mounted to the docker container at the path /source.
  2. The source folder in the current directory to be mounted to the docker container at the path /source.

Additional information you deem important (e.g. issue happens only occasionally):
The -v and the --mount flags should accept relative paths. Using $(pwd) on Linux and %cd% on Windows is not a pretty solution, and I have to include separate commands for Windows and Linux in my projects.

Output of docker version:

Client: Docker Engine - Community
Version: 19.03.8
API version: 1.40
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:23:10 2020
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.8
API version: 1.40 (minimum version 1.12)
Go version: go1.12.17
Git commit: afacb8b
Built: Wed Mar 11 01:29:16 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

Output of docker info:

Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 3
Server Version: 19.03.8
Storage Driver: overlay2
Backing Filesystem: <unknown>
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.19.76-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 983.4MiB
Name: docker-desktop
ID: EGN7:AJIT:6MIR:U54L:PZQX:5JCH:INTW:R3LC:77HP:5IKF:U2YX:Q4WQ
Docker Root Dir: /var/lib/docker
Debug Mode: true
File Descriptors: 34
Goroutines: 51
System Time: 2020-05-13T20:43:58.120001272Z
EventsListeners: 3
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Additional environment details (AWS, VirtualBox, physical, etc.):
Docker Desktop on Windows 10.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions