docker toolbox mount file on windows

afym picture afym · Oct 24, 2015 · Viewed 27.4k times · Source

I am a beginner with docker and I am using a windows machine. But I have a problem mounting files using volumes. The documentation says the following thing about mount files on OSX and windows :

Official docker docs :

Note: If you are using Docker Machine on Mac or Windows, your Docker daemon only has limited access to your OS X/Windows filesystem. Docker Machine tries to auto-share your /Users (OS X) or C:\Users (Windows) directory - and so you can mount files or directories using docker run -v /Users/:/ ... (OS X) or docker run -v /c/Users/:/

>> go to docker volumes docks

I have a small nginx Dockerfile

Dockerfile

FROM centos:6.6

MAINTAINER afym

ENV WEBPORT 80

RUN yum -y update; yum clean all

RUN yum -y install epel-release; yum clean all

RUN yum -y install nginx; yum clean all

RUN echo "daemon off;" >> /etc/nginx/nginx.conf

VOLUME /usr/share/nginx/html

EXPOSE $WEBPORT

CMD [ "/usr/sbin/nginx" ]

Creating a simple container

docker run -d --name simple -p 8082:80 ng1

8875448c01a4787f1ffe4c4c5c492efb039e452eff957391ac52a08915e18d66

enter image description here

Creating a container with a volume

My windows host directory

enter image description here

Creating the docker container with -v option

docker run -d --name simple2 -v /c/Users/src:/usr/share/nginx/html -p 8082:80 ng1
invalid value "C:\\Users\\src;C:\\Program Files\\Git\\usr\\share\\nginx\\html" 
for flag -v: bad mount mode specified 
: \Program Files\Git\usr\share\nginx\html
See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.

Inspecting the ng1 image

docker inspect ng1

enter image description here

What is wrong when I am creating a docker container with a volume?

Thanks.

Answer

Stanislav picture Stanislav · Oct 24, 2015

Try to run it with additional / for volume like:

docker run -d --name simple2 -v /c/Users/src://usr/share/nginx/html -p 8082:80 ng1

Or even for host OS, as

docker run -d --name simple2 -v //c/Users/src://usr/share/nginx/html -p 8082:80 ng1

Due to this issue:

This is something that the MSYS environment does to map POSIX paths to Windows paths before passing them to executables.