I have two local folders, the content of both is bind mounted into their own containers.
I also have the same named volume mounted to both in attempt to share files between containers while also bind mounting to local folders and keeping them up to date.
╔ /frontend
╠═ /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.
╔ /truffle
╠═ /contracts
╠═ /migrations
╚═ /test
volumes:
- ./truffle : /usr/src/truffle
- contracts : /usr/src/truffle/build
The current outcome is that the named volume "contracts" is bound to both containers correctly and saving a file in the truffle container reflects in the frontend container filesystem however it is not copied over locally through bind mounting to either local folder.
The local truffle folder does create a "build" folder to reflect changes in the container however it is empty even though the containers filesystem does have files in that folder.
The local frontend folder does not create the "contracts" folder which is present in the containers filesystem with files inside, I suspect this is due to bind mounting the actual local truffle folder rather than subfolders from the local frontend folder, regardless neither way copies the files inside their respective folders.
How can you use a named volume to share files between containers which have bind mounted folders to separate folder on the local machine?