An Ubuntu 14.04 based image, featuring s6 process management and nginx.
1.5K
An image for using nginx within containers.
Yet another container for running nginx?
Yes, as this one is built from my Ubuntu-based Docker image that contains s6 for process management.
Aren't you only supposed to run one process per container?
Well yes and no... the following are good examples of when multiple processes within one container might be necessary:
To use this image include FROM smebberson/nginx at the top of your Dockerfile, or simply docker run -p 80:80 -p 443:443 -t nginx smebberson/nginx.
This container comes setup as follows:
To start nginx using s6:
/etc/s6/nginxrun and give it execute permissionsIf you need to, you can run a setup script before starting nginx. During your Dockerfile build process, copy across a file to /etc/s6/nginx/run with the following (or customise it as required):
#!/usr/bin/env bash
if [ -e ./setup ]; then
./setup
fi
# start nginx
exec nginx;
A basic nginx configuration is supplied with this image. But it's easy to overwrite:
nginx.confDockerfile, make sure your nginx.conf file is copied to /etc/nginx/nginx.confMake sure you start nginx without daemon mode, by including daemon off; in your nginx configuration.
A default HTML file is also supplied, but again it's easy to overwrite:
default.htmlDockerfile, make sure your default.html file is copied to /var/lib/nginxThis is assuming you haven't changed the nginx.conf.
If you're running another process to keep track of something down-stream (for example, automatically updating nginx proxy settings when a down-stream application server (nodejs, php, etc) restarts (and the IP changes)) execute the command s6-svc -h /etc/s6/nginx to send a SIGHUP to nginx and have it reload its configuration, launch new worker process(es) using this new configuration, while gracefully shutting down the old worker processes.
By default, if nginx crashes, the container will stop. This has been configured within root/etc/s6/nginx/finish. This is so the host machine can handle any alerts, and automatically restart it.
If you don't want this to happen, simply replace the root/etc/s6/nginx/finish with a different file in your image. I like to ln /bin/true /root/etc/s6/nginx/finish in those instances.
Content type
Image
Digest
sha256:96cfd4309…
Size
129.9 MB
Last updated
over 11 years ago
docker pull smebberson/nginx