Here are some sample answers to the questions presented in this chapter:
The easiest way to play with volumes is to use the Docker Toolbox because when directly using Docker for Desktop, the volumes are stored inside a (somewhat hidden) Linux VM that Docker for Desktop 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 do the following exercise:
- 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 this command:
$ docker volume inspect my-products | grep Mountpoint
This (if you're using docker...