多个卷到单个目标目录? [英] multiple volumes to single target directory?

查看:130
本文介绍了多个卷到单个目标目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从主机上挂载多个卷以形成单个目标挂载点?有点像这样:

Is there a way to mount multiple volumes from a host to form a single target mount point? A bit like this:

docker run --name ubuntu_bash \
    --rm --interactive --tty \
    --volume=/media/Large/videos:/videos \
    --volume=/media/Small/videos:/videos \
    ubuntu find /videos

我猜答案不是,但是 overlay在Docker上下文中有很多含义,

I'm guessing the answer is no but with "overlay" having so many meanings in the context of Docker it's a bit difficult to search for this on the web.

如果没有,那么是否有可能会有用的Docker Store映像?不幸的是,许多Docker镜像没有给出足够的使用说明。

If not, is there a Docker Store image that might help? Unfortunately a lot of Docker images don't give sufficient instructions on how to use them.

推荐答案

没有内置的docker方法可以使用对卷执行此操作,它们通常是本地卷的绑定安装。 unionfs挂载用于创建容器的图像层,但是卷完全在其外部起作用,并挂载在unionfs之上,以拦截对该目录的所有文件系统请求。

There's no built in docker method to do this for volumes, they are typically a bind mount for local volumes. The unionfs mounts are for the image layers used to create your container, but volumes act completely outside of this and mount on top of the unionfs intercepting all filesystem requests to that directory.

如果您创建了使用Linux挂载执行此操作的解决方案,则可以使用相同的Linux挂载选项在docker中定义卷挂载。例如,在docker中进行NFS挂载的方法如下:

If you create a solution to do this with a linux mount, you can define a volume mount in docker with the same linux mount options. For example, the method to do an NFS mount in docker is the following:

# For a reusable volume
$ docker volume create --driver local \
    --opt type=nfs \
    --opt o=addr=192.168.1.1,rw \
    --opt device=:/path/to/dir \
    foo

# For a local container with docker run
$ docker run -it --rm \
  --mount type=volume,dst=/container/path,volume-driver=local,volume-opt=type=nfs,volume-opt=o=addr=192.168.1.1,volume-opt=device=:/host/path \
  foo

# For a swarm mode service
$ docker service create \
  --mount type=volume,dst=/container/path,volume-driver=local,volume-opt=type=nfs,volume-opt=o=addr=192.168.1.1,volume-opt=device=:/host/path \
  foo

请注意,在所有这些示例中,volume-driver是本地的,而volume-opt用于传递所有安装选项,就像在挂载命令。

Note in all of these examples the volume-driver is local, and volume-opt is used to pass all of the mount options like you would on a mount command.

这篇关于多个卷到单个目标目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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