简体   繁体   English

Docker-compose 挂载文件夹

[英]Docker-compose mount folder

Hi I have multiple folders that I wish to mount.嗨,我有多个要挂载的文件夹。 this is the scenario:这是场景:

On my host: path\\to\\mount\\HostFolder\\folder_*在我的主机上:path\\to\\mount\\HostFolder\\folder_*

On my container: \\path\\to\\mount\\ContainerFolder\\在我的容器上:\\path\\to\\mount\\ContainerFolder\\

* is a number * 是一个数字

I want to mount all folder_* to ContainerFolder\\ ContainerFolder already have some folders inside so I must not mount HostFolder to ContainerFolder to save them.我想将所有 folder_* 挂载到 ContainerFolder\\ ContainerFolder 里面已经有一些文件夹,所以我不能将 HostFolder 挂载到 ContainerFolder 来保存它们。

I wish to use regex but volume keyword doesn't seems to support it, any suggestions how to manage that?我想使用正则表达式,但volume关键字似乎不支持它,有什么建议可以管理它吗?

My only idea right now is script to write for me the docker-compose.我现在唯一的想法是为我编写 docker-compose 脚本。

My suggestion would be to seriously reconsider the assumption that you need the current directory structure.我的建议是认真重新考虑您需要当前目录结构的假设。 (Of course, this may be impossible, I know.) (当然,这可能是不可能的,我知道。)

If you can change the directory structure at all, you can try restructuring the folders like this:如果您可以更改目录结构,您可以尝试像这样重组文件夹:

  • ContainerFolder容器文件夹
    • folders文件夹
      • folder_1文件夹_1
      • folder_2文件夹_2

In this way, you can mount the HostFolder into a subdirectory of ContainerFolder without overwriting the contents of ContainerFolder itself.这样,您可以将 HostFolder 挂载到 ContainerFolder 的子目录中,而不会覆盖 ContainerFolder 本身的内容。

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

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