Docker Community Forums

Share and learn in the Docker community.

Basic Question on Named Mounts and Bind Mounts


(Mhickok) #1

Hello all, I have a silly question regarding volume mount in Docker.

I know that volumes were added to Docker some time ago and are the preferred way of providing persistent storage for containers.

However, as far as I can tell you are not able to specify the source location on the host unless you add a bunch of options to the volume.

For example, if I need to map /storage/data to a container in /opt/garbage as a named volume, I need to do something like this:

docker volume create --opt device=/storage/data --opt o=bind my_volume

docker run -it -v my_volume:/opt/garbage some_image

Here’s my question: if I am adding those options, specifically o=bind, is that still taking advantage of named volumes from a permissions perspective, or is it pretty much using the same mechanism as an old-school bind-mount?