docker info | less
command to see which storage driver is currently running. docker volume inspect my-vol
command.myvol2
into /app/
in the container.-v
and --mount
examples below produce the same result.docker inspect devtest
to verify that the volume was created and mounted correctly. Look for the Mounts
section.docker inspect devtest
to verify that the volume was created and mounted correctly. Look for the Mounts
section.-v
and --mount
behavior--mount
and -v
flags.docker export
command does not export the contents of volumes associated with the container. If a volume is mounted on top of an existing directory in the container, docker export
will export the contents of the underlying directory, not the contents of the volume.docker inspect devtest
to verify that the bind mount was created correctly. Look for the Mounts
section:docker inspect devtest
to verify that the bind mount was created correctly. Look for the Mounts
section-v
or --volume
flag was used for standalone containers and the --mount
flag was used for swarm services. However, starting with Docker 17.06, you can also use --mount
with standalone containers. In general, --mount
is more explicit and verbose. The biggest difference is that the -v
syntax combines all the options together in one field, while the --mount
syntax separates them. Here is a comparison of the syntax for each flag.--mount
syntax. Experienced users may be more familiar with the -v
or --volume
syntax, but are encouraged to use --mount
, because research has shown it to be easier to use.-v
and --mount
behavior-v
and --volume
flags have been a part of Docker for a long time, their behavior cannot be changed. This means that there is one behavior that is different between -v
and --mount
.-v
or --volume
to bind-mount a file or directory that does not yet exist on the Docker host, -v
creates the endpoint for you. It is always created as a directory.--mount
to bind-mount a file or directory that does not yet exist on the Docker host, Docker does not automatically create it for you, but generates an error.