5

I am trying to mount a host volume to a Docker container for MongoDB. The Dockerfile contains the following.

# Create the MongoDB data directory
RUN mkdir -p /data/db
# Identify mount point
VOLUME /data/db

--> The docker image has a name called mongo.

But when i try to start the image and mount a local Windows folder using:

docker run -d -v /c/Users/310145787/Desktop/mongo:/data/db mongo

I get an error message saying:

invalid value "c:\Users\310145787\Desktop\mongo;C:\Program Files (x86)\Git\data\db" for flag -v: \Users\310145787\Desktop\mongo;C:\Program Files (x86)\Git\data\db is not an absolute path

I checked with boot2docker ssh if the path is accessible and it seems ok. docker@boot2docker:/c/Users/310145787/Desktop/mongo

Any clue what is going wrong over here? Or what am i missing?

Using Boot2Docker 1.6, the Dockerfile can be found here

Marco
  • 15,101
  • 33
  • 107
  • 174
  • `VOLUME /data/db` is for data volume container. If you are mounting an host volume, you shouldn't need the `VOLUME` in your Dockerfile. Would the same docker run -v works on an image defined *without* `VOLUME`? – VonC Apr 22 '15 at 06:09
  • @VonC I recreated the image without the VOLUME and started it the same as i did before. Still getting the same error message. – Marco Apr 22 '15 at 06:15
  • Ok. Can you try without the `MKDIR` directive? I mount host folder all the time for docker-compose, and it always work (boot2docker 1.6 on Windows: http://stackoverflow.com/a/29728993/6309) – VonC Apr 22 '15 at 06:36
  • @VonC also a no go. Still the same error. I am puzzled on the error output it combines the provided path with the GIT install so maybe there is something going wrong. `flag -v: \Users\310145787\Desktop\mongo;C:\Program Files (x86)\Git\data\db is not an absolute path` – Marco Apr 22 '15 at 06:41
  • Can you try in a session where boot2docker is started with a minimal PATH (like: `C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\Oracle\VirtualBox;c:\prgs\Boot2DockerforWindows`) – VonC Apr 22 '15 at 07:02
  • Tried your suggestion with the following path settings in the bash shell. Exported by executing `env` in the shell `PATH=/c/Users/310145787/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/Windows:/c/Program Files/Oracle/VirtualBox:/c/Program Files/Boot2Docker for Windows:/usr/cmd:/usr/bin:/c/Users/310145787/AppData/Roaming/npm:.` Stil getting the same error. – Marco Apr 22 '15 at 07:31
  • Why the unix-style paths? When I start boot2docer, I do so in a CMD session with windows-like paths (and no `/usr/cmd` or other pure unix path). – VonC Apr 22 '15 at 07:33
  • When i start boot2docker via commandline or using the start.sh and check the environment using `env` i get these unix style paths. – Marco Apr 22 '15 at 07:34
  • The actual path set in WIndows System Properties is this.. `%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%systemroot%\System32\WindowsPowerShell\v1.0\;C:\Windows;C:\Program Files\Oracle\VirtualBox;C:\Program Files\Boot2Docker for Windows;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;` – Marco Apr 22 '15 at 07:35
  • Could you try with a PATH not including Git? And using boot2docker.exe start + ssh, as I do in https://github.com/VonC/b2d/blob/master/b2d.bat. – VonC Apr 22 '15 at 08:52
  • When trying the commands from the .bat file i got another error like: `C:\Users\310145787>boot2docker start Waiting for VM and Docker daemon to start... ..........................................................................oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo Started. Trying to get Docker socket one more time Error requesting socket: exec: "ssh": executable file not found in %PATH% Auto detection of the VM's Docker socket failed. Please run `boot2docker -v up` to diagnose.` – Marco Apr 22 '15 at 11:04
  • I also experience the seem as described here: https://github.com/boot2docker/windows-installer/issues/31 i have a feel that msysgit is not playing along very wel. – Marco Apr 22 '15 at 11:10
  • Here is my PATH: `Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\prgs\git\PortableGit-1.9.5-preview20141217\ bin;C:\Program Files\Oracle\VirtualBox;c:\prgs\Boot2DockerforWindows;C:\Users\VonC\prog\b2d\` – VonC Apr 22 '15 at 12:53
  • I do not follow how this solve the mounting problem, please. I have the same issu when mounting: `docker run -v /c/Users/Tomi:/mnt tomitrescak/meteor bash` I receive `invalid value "c:\\Users\\Tomi;C:\\Program Files (x86)\\Git\\mnt" for flag -v: \Users\Tomi;C:\Program Files (x86)\Git\mnt is not an absolute path` – tomitrescak Apr 23 '15 at 05:54
  • Do you run the command (`docker run`) in Windows or Boot2docker environment ? if windows, then try it in boot2docker-vm, which is unix env. – Larry Cai Apr 27 '15 at 08:23

2 Answers2

7

I was pointed out to a workaround. Instead of using a single slash /c/Users/ using a double slash works //c/Users/

I checked and the mounting of the volume works ok now!

Marco
  • 15,101
  • 33
  • 107
  • 174
5

I experienced the same problem.

see: https://github.com/docker/docker/issues/12590

If you're using git bash on windows, msysgit converts paths like /c/users to c:\users (not something you want because the path inside the boot2docker VM is /c/Users)

If you use cmd.exe or powershell you shouldn't be having this problem.

I was successfully able to mount a drive after I used cmd.

The Instructions below are for starting Boot2Docker with the windows cmd

Boot2Docker Up
set DOCKER_HOST=tcp://192.168.59.103:2376
set DOCKER_CERT_PATH=C:/Users/<yourusername>/.boot2docker/certs/boot2docker-vm
set DOCKER_TLS_VERIFY=1

docker run -d -v /c/Users/310145787/Desktop/mongo:/data/db mongo

You should be good to go :-)

Rob
  • 82
  • 4