When creating volumes through the volume API, that is, as the container volume pattern is now not necessarily the best practice anymore:
# docker volume inspect test-data
[
{
"Name": "test-data",
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/test-data/_data"
}
]
I would like to, for example, have docker volumes exist in /data (which is mounted in a different physical volume).
This is not possible to do with symbolic links, it is possible to do with bind mounts, but would I'm wondering if there is some configuration in Docker to change the default location for each separate volume.
# cd /var/lib/docker/volumes
# ln -s /mnt/myvolume myvolume
and then create the volume and start your docker image:# docker volume create --name myvolume
# docker run -v myvolume:/myvolumemountpoint ...
docker
will not allow deleting a volume if it is not a subdirectory of thedata_root
. (apparentlydocker
resolves the symlink for volumes.)