简体   繁体   English

在(Windows)主机上挂载容器卷而不进行复制

[英]Mount container volume on (windows) host without copying

I have a container that I start like 我有一个像这样的容器

docker run -it --mount type=bind,source=/path/to/my/data,target=/staging -v myvol:/myvol buildandoid bash -l

It has two mounts, one bind mount that I use to get data into the container, and one named volume that I use to persist data. 它有两个安装座,一个用于将数据获取到容器中的绑定安装座,另一个用于持久化数据的命名卷。 The container is used as a reproducable android (AOSP) build environment, so not your typical web service. 该容器用作可重现的android(AOSP)构建环境,因此不用作典型的Web服务。

I would like to access the files on myvol from the Windows host. 我想从Windows主机访问myvol上的文件。 If I use an absolute path for the mount, eg -v /c/some/path:/myvol , I can do that, but I believe docker creates copies of all the files and keeps them in sync. 如果我使用绝对路径进行安装,例如-v /c/some/path:/myvol ,则可以这样做,但是我相信docker会创建所有文件的副本并使它们保持同步。 I really want to avoid creating these files on the windows side (for space reasons, as it is several GB, and performance reasons, since NTFS doesn't seem to handle many little files well). 我真的想避免在Windows端上创建这些文件(出于空间原因,因为它是几个GB,并且出于性能原因,因为NTFS似乎不能很好地处理许多小文件)。

Can I somehow "mount" a container directory or a named volume on the host? 我可以以某种方式在主机上“装载”容器目录或命名卷吗? So the exact reverse of a bind mount. 因此,绑定安装的完全相反。 I think alternatively I could install samba or sshd in the container, and use that, but maybe there is something built into docker / VirtualBox to achive this. 我认为我可以在容器中安装samba或sshd并使用它,但是也许docker / VirtualBox内置了一些工具来实现这一点。

Use bind mounts. 使用绑定安装。

https://docs.docker.com/engine/admin/volumes/bind-mounts/ https://docs.docker.com/engine/admin/volumes/bind-mounts/

By contrast, when you use a volume, a new directory is created within Docker's storage directory on the host machine, and Docker manages that directory's contents. 相比之下,当您使用卷时,将在主机上的Docker的存储目录中创建一个新目录,并且Docker管理该目录的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM