Mounting a directory from the host in boot2docker for Windows

9,986

Solution 1

If you want to mount the $APPDATA on your Windows host machine to /datadir on the docker container, instead of the below command:

docker run -d --name abe -v $APPDATA/Bitcoin:/datadir poliver/bitcoin-abe

You can issue:

docker run -d --name abe -v //c/Users/YOUR_USER_NAME/$APPDATA/Bitcoin:/datadir poliver/bitcoin-abe

//c/Users/PATH_TO_DIR is the key here for Windows directory

Your $APPDATA Directory MUST reside on the /c/Users/Your_User_Name directory and it cannot reside on other places. (e.g. D:/$APPDATA on the D partition.)

Solution 2

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)

On cmd.exe/powershell you shouldn't be having this problem.

Share:
9,986

Related videos on Youtube

Paul Oliver
Author by

Paul Oliver

⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️ I love to code and manage projects. ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️ I ❤️ working with: AngularJS ASP.NET Web API AWS Azure EmberJS Docker DynamoDB Google Cloud Platform Java NGINX NodeJS Python Ruby on Rails SQL Server PostgreSQL

Updated on September 18, 2022

Comments

  • Paul Oliver
    Paul Oliver over 1 year

    I'm running docker 1.6 and boot2docker on a Windows 8.1 box. When I use the Boot2Docker Start shortcut, it takes me to a cygwin bash prompt where I can run docker commands natively.

    I'm having trouble mounting a directory from my users folder. I've tried:

    $ docker run -d --name abe -v $APPDATA/Bitcoin:/datadir poliver/bitcoin-abe
    

    I get the error:

    invalid value "C:\\Users\\someone\\AppData\\Roaming/Bitcoin:/datadir"
    for flag -v: \Users\someone\AppData\Roaming/Bitcoin:/datadir 
    is not an absolute path 
    See 'c:\Program Files\Boot2DockeForWindows\docker.exe run --help'.
    

    I get the same results when I call it these ways:

    $ docker run -d --name abe -v "$APPDATA/Bitcoin":/datadir poliver/bitcoin-abe
    $ docker run -d --name abe -v "/c/users/someone/AppData/Roaming/Bitcoin":/datadir poliver/bitcoin-abe
    $ docker run -d --name abe -v ~/AppData/Roaming/Bitcoin:/datadir poliver/bitcoin-abe
    

    I've also tried:

    $ docker run -d --name abe -v ~/APPDATA/Bitcoin:/datadir poliver/bitcoin-abe
    

    And I've gotten the error:

    FATA[0000] Error response from daemon: cannot bind mount volume: ~\AppData\Bitcoin volume paths must be absolute.
    

    It seems like cygwin bash is replacing / with \ and then docker parses the argument passed to -v and can't accept it.

    • Wilson Gibbins
      Wilson Gibbins about 9 years
      On my boot2docker installation, the command "ls /c/Users" lists my Windows 8.1 C:\Users folder. Do you need to mount other locations?
    • Paul Oliver
      Paul Oliver about 9 years
      I can certainly see /c/Users from the boot2docker linux VM (the host). But I need the poliver/bitcoin-abe container to mount a specific folder from /c/Users at the /datadir mount point on the container.
    • Marco
      Marco about 9 years
      I also seem to experience the same problem unable to mount a host folder. $ docker run -d -v /c/Users/310145787/Desktop/mongo:/data/db mongo 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
    • Marco
      Marco about 9 years
      Did you get a solution to your problem?
    • Paul Oliver
      Paul Oliver about 9 years
      Sorry Marco, no solution yet. :(