docker volumes
==============
Volumes vs bind mounts
----------------------
Read the overview [docker-volumes-01]_ for:
- Overview of mount types(volumes, bind mounts, tmpfs mounts, named pipes)
- Typical use cases for each type
- Tips for bind mounts or volumes (what happens when mounting to a
directory in the container in which some files or directories exist)
In general, the docker docs recommend to use volumes [docker-volumes-02]_ over
bind mounts [docker-volumes-03]_
VOLUME declaration in Dockerfile
--------------------------------
Docker docs [docker-volumes-04]_:
- The VOLUME instruction creates a mount point with the specified name
and marks it as holding externally mounted volumes from native host
or other container
- The docker run command initializes the newly created volume with any
data that exists at the specified location within the base image
Difference between Dockerfile VOLUME, docker volume command,
docker run -v [docker-volumes-05]_:
- When defined in the Dockerfile, each time a container is started
from the image, the volume is created, even if the docker run
does not have any -v option.
- docker volume create creates a volume without having to define a
Dockerfile and build an image and run a container
- You can declare it on runtime docker run -v [host-dir:]container-dir.
combining the two (VOLUME + docker run -v) means that you can mount
the content of a host folder into your volume persisted by the
container in /var/lib/docker/volumes/...
References
----------
.. [docker-volumes-01] `Storage Overview: Manage data in Docker (docs.docker.com)
`_
(Retrieved 2021-08-20)
.. [docker-volumes-02] `Volumes (docs.docker.com)
`_
(Retrieved 2021-08-20)
.. [docker-volumes-03] `Bind mounts (docs.docker.com)
`_
(Retrieved 2021-08-20)
.. [docker-volumes-04] `Dockerfile reference: VOLUME (docs.docker.com)
`_
(Retrieved 2021-08-22)
.. [docker-volumes-05] `What is the purpose of VOLUME in Dockerfile (stackoverflow.com)
`_
(Retrieved 2021-08-22)