Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

docker-nginx

Forked from dockerfile/nginx to use Debian instead of Ubuntu. Some additional parts added based on sameersbn/docker-postgresql and my fork of that, erikano/docker-postgresql.

Branch names in this repository reflect the image tags built from them. Note well that the "latest" tag does not refer to the current version of Nginx but instead, it is referring to to the latest changes of the image itself, whatever they may be. The currently recommended stable image as of this writing is the one tagged "1.6", development of which is to find in the branch of the same name.

Installation

Using pre-built image

docker pull erikano/docker-nginx:latest

Building it yourself

mkdir -p ~/src/github.com/erikano/
cd ~/src/github.com/erikano/
git clone https://github.com/erikano/docker-nginx.git
cd docker-nginx
docker build -t="erikano/docker-nginx:$( git rev-parse --abbrev-ref HEAD )" .

Configuration

Data Store

For data persistence, certain volumes should be mounted within the container.

Create the directories on the host.

sudo mkdir -p \
  /opt/nginx/certs \
  /opt/nginx/conf.d \
  /opt/nginx/sites-available \
  /opt/nginx/sites-enabled \
  /opt/nginx/logs \
  /opt/nginx/html

If using SELinux, see issue #1.

Usage

Running

Default

Data is not persisted. Use only where loss of data doesn't matter.

docker run --name nginx -d -p 80:80 erikano/docker-nginx:latest

Bind-mounted volume for data persistence

I.e. what you almost certainly want to be doing in production.

docker run --name nginx -d -p 80:80 \
  -v /opt/nginx/certs:/etc/nginx/certs \
  -v /opt/nginx/conf.d:/etc/nginx/conf.d \
  -v /opt/nginx/sites-available:/etc/nginx/sites-available \
  -v /opt/nginx/sites-enabled:/etc/nginx/sites-enabled \
  -v /opt/nginx/logs:/var/log/nginx \
  -v /opt/nginx/html:/var/www/html \
  erikano/docker-nginx:latest

Connecting to the container

Executing bash as root within the container

Useful for debugging and maintenance.

docker exec -it nginx bash

Please note that the Debian image is quite slim so you will find
that some utilities you might expect to have, such as man and netstat,
are missing.

For a development container, it could be a good idea to modify the
Dockerfile to install utilities you need for debugging.
Just ensure that your development and production containers
don't diverge too much from one another or you'll end up with
things which worked in dev but break in prod ;)

Upgrading the container

Please note that these instructions apply to updating containers
for the same versions of Nginx. That is, this only applies
for changes to the Dockerfile and surrounding parts.

Pre-built image

docker pull erikano/docker-nginx:latest \
&& docker stop nginx \
&& docker rm nginx

Start the new image by issuing the usual run command.

Self-built image

cd ~/src/github.com/erikano/docker-nginx/ \
&& git pull \
&& docker build -t="erikano/docker-nginx:$( git describe )" . \
&& docker stop nginx \
&& docker rm nginx

Start the new image by issuing the usual run command.

Docker Pull Command
Owner
erikano
Source Repository

Comments (0)