Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker run -v <dir> vs Dockerfile's VOLUME <dir>

Tags:

docker

Is there any relationship between mounting volume with docker run -v command and Dockerfile's VOLUME instruction?

like image 914
arkadiy kraportov Avatar asked Sep 27 '22 05:09

arkadiy kraportov


1 Answers

The -v option can be used to bind a directory on the host to the container, but the VOLUME instruction cannot. Other than that they are two different ways for making a volume available in the container.

Both instructions create a mount point in the container, but only -v can actually mount anything there.

See:
http://docs.docker.com/engine/reference/builder/#volume and
http://docs.docker.com/engine/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume
for more in-depth descriptions of what both do.

like image 86
madsen Avatar answered Sep 30 '22 07:09

madsen