Reputation: 2796
Could I run a container with only static html file and use a Nginx container to proxy the request to it? My idea is use an Nginx container to proxy the request to multiple website but those websites only contain static html file, is that possible?
I already build a docker image with static file
FROM alpine:3.7
COPY /build/ /srv/www/web/
there is only an index.html in the build folder then I run this image then got status with Exited (0)
Upvotes: 0
Views: 2782
Reputation: 78
If you want a single NGINX to proxy requests to multiple websites you can try to follow this guide. It is a quite common thing to do, if you want for example to add TLS / SSL to all the sites you have. I have for example 10 subdomains, and a single proxy that routes calls to each individual site while adding TLS / SSL. I use traefik instead of NGINX though, as it has better Lets Encrypt support.
Upvotes: 0
Reputation: 1035
When you run a docker image, it will run a single process - see CMD instruction in the Dockerfile documentation. Your static file container does not have any process to run, so it will exit immediately.
You can use the nginx image to serve static files - search for nginx on dockerhub: the howto section of that image will tell you how. (Basically either mount the static files as a volume, or create a derivative image by adding the files to it)
edit
To serve multiple sites, you have to configure nginx. The nginx docker image documentation "complex configuration" section shows an example how to mount a custom nginx.conf. You have to read the nginx documentation how to set up multiple sites.
So from docker perspective you only need the nginx image. In the simplest case all your sites files are under a single directory which you have to mount as a docker volume. And you need to mount your custom nginx.conf.
edit2
However, if you only want to run nginx on one server, then it is probably not worth to use docker. Just install nginx on the server.
Upvotes: 1