Docker Community Forums

Share and learn in the Docker community.

Nginx with Docker


(Rubendario) #1

Hi, im using Nginx as server web of my services in docker (Docker-hub), is a good idea use Nginx as static files server?, or i must be use static files with application in the same container, i mean, i want use my application in container A with static files in container b, Container A = Application, Container B = Nginx.

(Jmiraglia) #2

This is how I have my infrastructure setup. Nginx is serving all static files (images, styles, javascript) and passing all other requests down to PHP-fpm containers.

(Rubendario) #3

Thanks for answering, and yeah i understand but, how i can serve all static files or expose it, i don’t have access to docker ip from my python application inside in another docker.
I mean the application has static = ‘/home/user/static/’, but these directory is in another docker with diferent ip

(Jmiraglia) #4

You should be able to do this with shared volumes:

Or you could bake your files into the nginx image when it is built (this is what I am doing).

My traffic flows like Traffic > Nginx > PHP