Public | Automated Build

Last pushed: a month ago
Short Description
This is an automated build for
Full Description

nginx web server container

This is an example of how nginx can be easily run in a Docker container. Please note that this version is not suitable for production use, but feel free to tinker with it. This container is built on top of base-runtime (a minimal image) and uses nginx module.


To build or run the nginx container, some components are required that aren't
in the Base Runtime image.

Build Dependencies

  • GeoIP
  • gperftools

Runtime Dependencies

  • mailcap


This repository containes file nginx.conf in files folder, where you can configure all the settings you need for nginx to suit your needs. However, please don't change the following lines, as they are needed for proper functionality in a container.

error_log stderr;
daemon off;

These lines will redirect error log to stderr and prevent nginx from demonizing itself, which if enabled, would result in docker stopping the container right after starting it, because the root process would exit right after spawning worker processes.

Running in Docker

You can get this continer image from docker hub:

$ docker pull modularitycontainers/nginx

This container can be run in two ways:

1) From shell

docker run --rm -p 8080:80 -v <DIR>:/var/www/html/

This starts the container and forwards port 80 from container to port 8080 on host. You can replace \<DIR> with location of your web root. Please note that this has to be an absolute path, due to Docker requirements.

2) With a Makefile

In order to simplify running the container, you can use a supplied Makefile. By default it will only build the image and tag it. If you set the DOCUMENT_ROOT variable, executing make will also run the container. You can set the following options there:

# Docker container tag
IMAGE_NAME = nginx

# An absolute path to your web root

# A port you want your nginx server to run on host
PORT = 8080

Running in Openshift

To run this container in OpenShift, you need to change the RunAsUser option in the restricted Security Context Constraint (SCC) from MustRunAsRange to RunAsAny. Do it by running:

$ oc login -u system:admin
$ oc project default
$ oc edit scc restricted

Find RunAsUser and change its value from MustRunAsRange to RunAsAny. This is needed as nginx master process is running as a root.

Then you can run openshift-template.yml in this repository:

$ oc login -u developer
$ oc create -f openshift-template.yml
Docker Pull Command
Source Repository

Comments (0)