Boot2Docker mount host volume to externalize data using Windows

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.

  • sbt-docker difference between add and addRaw
  • docker start a container after stopping
  • change db:5432 to 127.0.0.1:5432 in docker-compose file
  • Docker error The command non-zero code: 1 python
  • Docker centos7 image - unable to run apache
  • Docker-compose trouble to mount local volume
  • 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

  • Docker Swarm Linking
  • How can I use a local image as the base image with a dockerfile?
  • How can I create a docker image from the current system?
  • Multiple websites running in docker containers, how to implement?
  • Docker container reach outside network addresses
  • Installed gems not found by bundler when BUNDLE_PATH changed with Docker
  • 2 Solutions collect form web for “Boot2Docker mount host volume to externalize data using Windows”

    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 🙂

    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!

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.