I'm confused with what is different between creating docker volume create my-vol
and VOLUME ["/var/www"]
.
My understanding is:
1) docker volume create my-vol
creates a persistent volume on our machine and each container could be linked to my-vol
.
2) VOLUME ["/var/www"]
creates a volume inside its container.
And when I create another container, I could link
my-vol
as follows: when running a container$ docker run -d --name devtest --mount source=myvol2,target=/app nginx:latest
At that time, if I added
VOLUME ["/var/www"]
in my Dockerfile, all data of this docker file will be stored in bothmyvol2
and/var/www
?