Volumes is a docker concept which allows you to have persistent storage within a docker container. It also allows files to be shared between the docker container and the host machine.
Creating A Docker Volume
A Docker volume can be associated with a host directory. This is specified as part of the
-v option. Unlike the container path, which must be absolute, the host directory can be relative.
The following command will mount the relative host directory
/root/ inside the container.
$ docker run -it -v my-volume:/root container
Using A Dockerfile
Be careful with your placement of the
VOLUME command inside a Dockerfile, as it essentially creates an immutable folder structure from that point forwards. Any modifications to the mount directory (or any sub-directory) will not be present when you create a container from the built image.