cancel
Showing results for 
Search instead for 
Did you mean: 
fausap
Cadet
Cadet
  • 1,326 Views

--volume vs --mount

Hello all,

is there any difference between the two flags? I understand that --mount is needed if you need to specify some mount flags, like ro.

But if you want to mount a named volume with default permissions, for example, the same can be done also with --volume (or -v), is it correct?

thanks,

Fausto

1 Reply
Chetan_Tiwary_
Community Manager
Community Manager
  • 1,322 Views

Hello @fausap !

You are right ! If you need to specify any mount flags, such as ro for read-only access, you should use the --mount flag.

The main difference  is that the -v syntax combines all the options together in one field, while the --mount syntax separates them in multiple key: value pairs. The --mount syntax is more verbose than -v or --volume.

If you use -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.

If you use --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.

It is not possible to modify the selinux label using the --mount flag.

 

 

 

 

Join the discussion
You must log in to join this conversation.