Pointing nginx container to static files in docker Pointing nginx container to static files in docker nginx nginx

Pointing nginx container to static files in docker


I think what you want to achieve should be done by mounting a volume of container 'api' to container 'nginx', something like this:

version: "3"services:  api:    image: apiimg    volumes:      - apivol:/path/to/statics  nginx:    image: nginximg    volumes:      - apivol:/var/www/staticsvolumes:  apivol: {}

So there's a shared volume declared for all containers, apivol, which is mapped to /path/to/statics on your Rails container, and to /var/www/statics in your nginx container. This way you don't need to copy anything manually into the nginx container.


The default location for static content on nginx is /etc/nginx/html, but you could put it in var/www/app_name as long as you remember to add

root /var/www/app_name

in the corresponding location block for your static content.