Itβs a little difficult to follow, but it looks like you are creating an image by outputting the files to what you think is the volume and trying to use it to populate the named volume used by another running container.
Most likely, your confusion is that when you create a container, volumes are not mounted, volumes are mounted only in running containers. A named volume has a function in which it will be filled with the contents of the image, but only when mounting a named volume that is empty. It looks like you use this feature the first time you build build +, but it will not work again in future builds. If you run the assembly container without a volume, you will find that your files are there as expected.
You can easily update a named volume. Two options come to mind. One of them is to use your current process, but change the mount point of the volume to something like "/ target" and as your CMD your build container, copy the contents of your source to "/ target". It will look like this:
Dockerfile
... RUN compile-cmd --output-to /local/build/dir
entrypoint.sh:
cp -a /local/build/dir/* /target/
docker-compose.yml:
version: '2' services: webapp_build: build: context: . dockerfile: 'config/nginx/dockerfile-builder' volumes: - webapp_build_volume:/target ...
The second option is to not do this in the container assembly at all, but rather make a container with your application that compiles the prerequisites. Then mount your application code as a volume in this container using CMD or ENTRYPOINT , which takes the contents of the code volume, compiles it, and outputs it to the named volume, which is also mounted. Then, instead of creating an assembly container, you simply start the compilation container with two volumes installed.
entrypoint.sh:
compile-cmd --input-src=/source --output-to /target
docker-compose.yml:
version: '2' services: webapp_build: volumes: - app/source:/source - webapp_build_volume:/target ...
source share