gpt4 book ai didi

Docker - 将容器目录暴露给主机目录而不掩盖原始内容

转载 作者:行者123 更新时间:2023-12-01 15:07:01 25 4
gpt4 key购买 nike

我对 Docker 还是比较陌生,所以我还没有完全弄清楚所有的细微差别,如果这个问题已经在其他地方解决了,请原谅我。

我想在容器和主机之间共享文件。
到目前为止,我一直在使用卷,并将特定的主机目录挂载到容器目录——但这会带来一个问题,如果主机目录被弄乱了,这些更改也会出现在容器中。

我遇到的另一个问题是,如果主机目录是空的,并且挂载到容器上预先存在的目录,那么目录的内容将不可见。我知道这种行为与安装一致,所以我知道这在技术上不是问题。

但我想知道是否可以设置一个卷或替代解决方案:

  • 首先不能在主机端编辑,
  • 其次允许主机目录内容与容器目录合并

最佳答案

I wonder if it would be possible to set up a volume, or an alternative solution, that

firstly cannot be edited on the host side,

那将是一个 data volume container (with docker create on an image with a VOLUME directive)

and secondly allows for the host directory contents to be merged with the container's directory?

据我所知没有。 You would have to do some kind of copy on startup .

关于Docker - 将容器目录暴露给主机目录而不掩盖原始内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34311166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com