Otherwise, I will have to create these static assets on the host side and then include it as a volume in the web container and share it with the nginx container.
This statement seems incorrect.
If static assets are generated as part of the build process, then simply mount the volume on top of this directory at run time. Docker will take care of copying the base content in that, after which you can access it in your nginx container using --volumes-from .
For example, if I start with this Dockerfile for my web container:
FROM alpine RUN apk add --update darkhttpd COPY assets /assets CMD ["darkhttpd", "/assets"]
Now I have a /assets directory containing my static assets. If I run this image as:
docker run -v /assets --name web web
Then /assets will (a) be volume and (b) contain the contents of the /assets directory.
Now you can start the nginx container and share this data with it:
docker run --volumes-from web nginx
The nginx container will have a /assets directory that contains static assets.
I have compiled a small example here .
source share