如何使用命名卷在容器之间共享文件并将卷绑定挂载到 Docker 中的两个单独的本地计算机文件夹?

How can you use a named volume to share files between containers and also bind mount the volume to two separate local machine folders in Docker?

/前端
╠═ /public
╚═ /src

    volumes:
        // the "contracts" folder does not exist locally however should be copied from the container after
        // mounting the named volume "contracts" in the container.
        - ./frontend/contracts : /usr/src/frontend/contracts 
        - ./frontend/src       : /usr/src/frontend/src
        - ./frontend/public    : /usr/src/frontend/public  
        - contracts            : /usr/src/frontend/contracts

NOTE:
using - ./frontend:/usr/src/frontend does not resolve the issue nor is it a desired solution because i dont want to copy over "node_modules" from the container onto the local machine.

/松露
╠═ /合同
╠═ /迁移
╚═ /测试

    volumes:
        - ./truffle             : /usr/src/truffle  
        - contracts             : /usr/src/truffle/build

当前结果是命名卷“contracts”正确绑定到两个容器,并且在 truffle 容器中保存文件反映在前端容器文件系统中,但是它没有通过绑定安装到本地文件夹复制到本地.

本地 truffle 文件夹确实创建了一个“build”文件夹来反映容器中的更改,但是它是空的,即使容器文件系统在该文件夹中确实有文件。

本地前端文件夹不会创建容器文件系统中存在的“contracts”文件夹,我怀疑这是由于绑定安装了实际的本地松露文件夹而不是本地前端文件夹中的子文件夹,无论哪种方式都不会将文件复制到各自的文件夹中。

如何使用命名卷在已将挂载文件夹绑定到本地计算机上的单独文件夹的容器之间共享文件?

我决定将与两个本地文件夹位于同一目录中的文件夹绑定到两个容器,并从它们访问该文件夹。该解决方案对我来说已经足够了,感谢您指出可能的解决方案! @大卫迷宫

示例本地文件结构:
╔═ /前端
╠═ /松露
╚═ /合同

docker 中的两个容器卷组成:

volumes:
    - ./contracts:/usr/src/frontend|truffle/contracts