Unable to use the volume flag with a windows container

2

I am trying to map a host folder to the guest in the same way that is easily accomplished on linux/mac via -v "$(pwd)":/code. I can't come up with a simple example to make this work with Windows Containers.

docker build -t="webdav" .
docker run --rm -it -v C:\junk:C:\code --name webdav webdav powershell


C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container f0fa313478fddb73e34d47699de0fc3c2a3bdb202ddcfc2a124c5c8b7523ec09 encountered an error during Start: failure in a Windows system call: The connection with the Virtual Machine hosting the container was closed. (0xc037010a).

I have tried countless other variations, and the accepted answer here gives the same error.

The docs seem to only refer to Docker Toolbox. The example only gives me invalid bind mount spec.

My Dockerfile

FROM microsoft/windowsservercore

RUN powershell -Command Add-WindowsFeature Web-Server

RUN powershell -Command mkdir /code

WORKDIR /code
ADD * /code/

OS Name: Microsoft Windows 10 Pro OS Version: 10.0.14393 N/A Build 14393

Version 17.03.1-ce-win5 (10743) Channel: stable b18e2a5

Disclaimer: I originally posted this on the docker forums but haven't had any responses.

docker-volume
docker-for-windows
docker
asked on Stack Overflow Apr 11, 2017 by wtjones • edited Aug 14, 2019 by Community

2 Answers

5

EDIT: Found it. https://docs.docker.com/engine/reference/builder/#volume "When using Windows-based containers, the destination of a volume inside the container must be one of: a non-existing or empty directory; or a drive other than C:"

Or here: https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only "The following examples will fail when using Windows-based containers, as the destination of a volume or bind-mount inside the container must be one of: a non-existing or empty directory; or a drive other than C:. Further, the source of a bind mount must be a local directory, not a file."

It strikes me that these are non-obvious places to document this difference. Where did you look for documentation of this issue? I'll add this there :)

Is there a general need for a summary of differences between Linux and Windows?

OLD ANSWER (for context) Here's a step-by-step guide on mounting volumes with the GUI: https://rominirani.com/docker-on-windows-mounting-host-directories-d96f3f056a2c

From reading through some other forum posts it sounds like special characters in passwords may trip things up.

If you are still having issues here is one thread you could read through: https://github.com/docker/docker/issues/23992

Hope this helps!

answered on Stack Overflow Apr 14, 2017 by Myles Keating • edited Apr 20, 2017 by Myles Keating
0

I'm not sure if/where the moby repo docs publish to Docker docs, but this issue indicates that a volume cannot reference an existing folder in the container. In my example, I was first creating c:\code. If I change the command:

docker run --rm -it -v C:\junk:C:\code2 --name webdav webdav powershell

... it will create and mount c:\code2 in the container to point to c:\junk on the host.

answered on Stack Overflow Apr 20, 2017 by wtjones

User contributions licensed under CC BY-SA 3.0