Description
Official Docker documentation are usually not very useful, and alot of times things remain unclear even after reading through their sections.
There are many things unclear, but this question I just want to target these:
When running docker volume create
:
--driver --opt device --opt type
When I run docker volume create --driver local --opt device=:/var/www/html/app --opt type=volume volumename
I actually do get a volume :
$docker volume inspect customvolume`
[
{
"CreatedAt": "2020-08-03T09:28:10Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/customvolume/_data",
"Name": "customvolume",
"Options": {
"device": ":/var/www/html/customfolder",
"type": "volume"
},
"Scope": "local"
}
]
Trying to mount this new volume:
docker run --name test-with-volume \
--mount source=customvolume,target=/var/www/html/app77' \
my-app-only:latest
Error:
Error response from daemon: error while mounting
volume '/var/lib/docker/volumes/customvolume/_data': failed to
mount local volume: mount :/var/www/html/customfolder:/var/lib/docker/volumes/customvolume/_data: no such device.
Questions
Clearly the options allow you to do some unexpected things, I was able to create a volume
volume at a custom location, but it is not mountable.
What are the options for
type
(with difference of each explained) : when usingdocker volume create
, they are unclear to me.docker run --mount
documentation talks aboutvolume, bind, tmp
, but ondocker volume create
they only show examples, which are tmpfs, btrfs, nfs.When can you use
device
?
I thought this could be used to create a custom location for volume type (aka named volumes) on the source host (similar to how bind-mounts can be mounted) I assumed I could use the 'recommended way of named volumes including a custom folder location' instead of host mounts (bind-mounts).Finally, how could you setup a docker-compose.yml volume custom driver correctly as well.
I think the confusion lies in the fact that docker run --mount
vs docker volume create
seems to be inconsistent, because of how unclear Docker documentation quality is