This is an improvement of the selected answer because that answer is limited to c:Users folder. If you want to create a volume using a directory outside of c:Users this is an extension.
In windows 7, I used docker toolbox. It used Virtual Box.
- Open virtual box
- Select the machine (in my case default).
- Right clicked and select settings option
- Go to Shared Folders
- Include a new machine folder.
For example, in my case I have included:
**Name**: c:dev
**Path**: c/dev
- Click and close
- Open "Docker Quickstart Terminal" and restart the docker machine.
Use this command:
$ docker-machine restart
To verify that it worked, following these steps:
- SSH to the docker machine.
Using this command:
$ docker-machine ssh
- Go to the folder that you have shared/mounted.
In my case, I use this command
$ cd /c/dev
- Check the user owner of the folder. You could use "ls -all" and verify that the owner will be "docker"
You will see something like this:
docker@default:/c/dev$ ls -all
total 92
drwxrwxrwx 1 docker staff 4096 Feb 23 14:16 ./
drwxr-xr-x 4 root root 80 Feb 24 09:01 ../
drwxrwxrwx 1 docker staff 4096 Jan 16 09:28 my_folder/
In that case, you will be able to create a volume for that folder.
You can use these commands:
docker create -v /c/dev/:/app/dev --name dev image
docker run -d -it --volumes-from dev image
or
docker run -d -it -v /c/dev/:/app/dev image
Both commands work for me. I hope this will be useful.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…