The easiest way to play with volumes is to use the Docker Toolbox as when directly using Docker for Mac or Docker for Windows, then the volumes are stored inside a (somewhat hidden) Linux VM that Docker for Mac/Win uses transparently.
Thus, we suggest the following:
$ docker-machine create --driver virtualbox volume-test
$ docker-machine ssh volume-test
And now that you're inside a Linux VM called volume-test, you can execute the following exercises:
- To create a named volume run the following command:
$ docker volume create my-products
- Execute the following command:
$ docker container run -it --rm \
-v my-products:/data:ro \
alpine /bin/sh
- To get the path on the host for the volume use, for example, this command:
$ docker volume inspect my-products | grep Mountpoint
Which (if using docker-machine and VirtualBox) should result in:
"...