Answers
Here are the answers to this chapter’s questions:
- 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 achieve this result, do this:
- To get the path on the host for the volume, use this command
$ docker volume inspect my-products | grep Mountpoint
- This should result in the following output
"Mountpoint": "/var/lib/docker/volumes/my-products/_data"
- Now, execute the following command to run a container and execute
nsenter
within it:
$ docker container run -it --privileged --pid=host \
debian nsenter -t 1 -m -u -n -i sh
- Navigate to the folder containing the data for the
my-products
volume:
/ # cd /var/lib/docker/volumes/my-products/_data
- Create a file containing the text
"I love Docker"
within this folder:
/ # echo "I love Docker...