有没有办法在docker中使用默认卷驱动器选择命名卷的路径? [英] Is there a way to choose the path of named volumes with the default volume drives in docker?

查看:112
本文介绍了有没有办法在docker中使用默认卷驱动器选择命名卷的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过docker中的默认卷驱动器选择命名卷的路径?

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

我知道我可以在每个服务中绑定装载卷。我知道我可以在服务之外创建命名卷,并通过在每个服务中装入它们来共享它们。但是我找不到在我选择的路径而不是docker的/ var / lib / docker / volumes /上获取(共享)数据的方法。

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/.

有人试图在同一docker-compose文件的两个不同容器中共享一个卷作为挂载点,而该卷是您选择的位置?

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?

推荐答案

您不能使用内置的docker volume插件来做到这一点。您需要安装如下所示的第三方插件

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

这篇关于有没有办法在docker中使用默认卷驱动器选择命名卷的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆