I've set up the latest Docker Desktop 2.1.0.5 in Windows 10 and creating and running simple/trivial containers i.e. docker run --rm -v c:/Users:/data alpine ls /data
works fine.
However, I'm having trouble (1) creating a volume tied to a folder on the Windows host and asking a Linux container to use it; and (2) specifying a DockerFile for that container. Here's what I tried:
- I created a volume via the command
docker volume create --driver local --opt type=none --opt device=c:\path\to\folder --opt o=bind test_vol
, and tried to mount it like this:docker run --rm -v test_vol:/data alpine ls /data
. This gives me the error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/test_vol/_data': failed to mount local volume: mount c:\path\to\folder:/var/lib/docker/volumes/test_vol/_data, flags: 0x1000: no such file or directory.
However, if I specify that host folder in the docker run
command without going through a previously-created volume (like this: docker run --rm -v c:\path\to\folder:/data alpine ls /data
) then it works fine.
- Specifying a DockerFile is also problematic. If I use this command:
docker run --rm --env-file c:\path\to\DockerFile -v c:\path\to\folder:/data alpine ls /data
, I get this error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: read c:\path\to\DockerFile: The handle is invalid. See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.
- For the above, I've tried changing the direction of the slashes (
/
vs\
) and putting the paths in quotes, but none of that helped or changed the error output. - I made sure that "Shared Drives" is turned ON in Docker Desktop Settings.
I'm very confused about how to specify these paths in Docker for Windows. Can someone please advise on how to troubleshoot this? Thank you.