Is there a way to choose the path of named volumes with the default volume drives in docker?

这一生的挚爱 提交于 2019-12-24 08:22:35

问题


Is there a way to choose the path of named volumes with the default volume drives in docker?

I know I can bind mount volumes in each service. I know I can create named volumes outside of services and them share them by mounting them in each service. But I can't find out a way to get the data (to be shared) on a path that I select instead of docker's /var/lib/docker/volumes/.

Anyone tried to share a volume as a mount point in two different containers of the same docker-compose file where the volume is a location at your choosing?


回答1:


You cannot do that with the built-in docker volume plugin. You need to install a thirdparty plugin like below

https://github.com/CWSpear/local-persist

curl -fsSL https://raw.githubusercontent.com/CWSpear/local-persist/master/scripts/install.sh | sudo bash

docker volume create -d local-persist -o mountpoint=/data/images --name=images

docker run -d -v images:/path/to/images/on/one/ one
docker run -d -v images:/path/to/images/on/two/ two


来源:https://stackoverflow.com/questions/46146086/is-there-a-way-to-choose-the-path-of-named-volumes-with-the-default-volume-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!