I was looking for an explanation on the VOLUME entry when writing a Dockerfile and came across this statement
A volume is a persistent data stored in
/var/lib/docker/volumes/...You can either declare it in a
Dockerfile, which means each time a container is started from the image, the volume is created (empty), even if you don't have any-voption.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/...
docker volume createcreates a volume without having to define aDockerfileand build an image and run a container. It is used to quickly allow other containers to mount said volume.
But I'm having a hard time understanding this line:
...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/...
For example, let's say I have a config file on my host machine and I run the container based off the image I made with the Dockerfile I wrote. Will it copy the config file into where the volume that I stated in my the volume entry?
Would it be something like (pseudocode)
#dockerfile
From Ubuntu
Run apt-get update
Run apt-get install mysql
Volume . /etc/mysql/conf.d
Cmd systemcl start MySQL
And when I run it
docker run -it -v /path/to/config/file: ubuntu_based_image
Is this what they mean?