I have some containers for a web app for now (nginx, gunicorn, postgres and node to build static files from source and a React server side rendering). In a Dockerfile for the no
Two changes you need. In your node service add the volume like:
volumes:
- vnode:/usr/src/bundle_client
Since you want to share /usr/src/bundle_client
you should NOT be using /usr/src/
because that will share the full folder and the structure too.
And then in your nginx service add the volume like:
volumes:
- type: volume
source: vnode
target: /var/www/test/static
volume:
nocopy: true
The nocopy: true
keeps our intention clear that on initial map of the container the content of the mapped folder should not be copied. And by default the first container to get mapped to the volume will get the contents of the mapped folder. In your case you want this to be the node
container.
Also before testing make sure you run below command to kill the cached volumes:
docker-compose down -v
You can see during my test the container had the files: