Git Product home page Git Product logo

docker-nginx's Introduction

Table of Contents

Installation

docker pull romeoz/docker-nginx

or development version (1.17.*):

docker pull romeoz/docker-nginx:dev

Alternately you can build the image yourself.

git clone https://github.com/romeoz/docker-nginx.git
cd docker-nginx
docker build -t="$USER/docker-nginx" .

Quick Start

Run nginx container:

docker run --name app -d -p 8080:80 romeoz/docker-nginx

The simplest way to login to the app container is to use the docker exec command to attach a new process to the running container.

docker exec -it app bash

Linked to other container

Create bridge networking:

docker network create app_net

A new API available since Docker 1.9+

As an example, will link with PHP.

docker run --name app -d \
    --net app_net
    -v /host/to/app:/var/www/app \
    romeoz/docker-phpfrpm

Contains sites-enabled/app.conf:

upstream backend {
    server app:9000;
}

server {
    listen   80 default_server;
    #listen [::]:80 ipv6only=on;

    root /var/www/app/;
    server_name app;
    index index.php;
    charset utf8;
  
    location /
    {
        rewrite ^ /index.php last;
    }

    location /index.php
    {
        include fastcgi.conf;
        fastcgi_pass backend;
    }
}

Run the nginx container:

docker run --name nginx -d \
    -v /host/to/sites-enabled:/etc/nginx/sites-enabled \
    --net app_net -p 8080:80 \ 
    romeoz/docker-nginx

Logging

All the logs are forwarded to stdout and sterr. You have use the command docker logs.

docker nginx app

####Split the logs

You can then simply split the stdout & stderr of the container by piping the separate streams and send them to files:

docker logs nginx > stdout.log 2>stderr.log
cat stdout.log
cat stderr.log

or split stdout and error to host stdout:

docker logs nginx > -
docker logs nginx 2> -

####Rotate logs

Create the file /etc/logrotate.d/docker-containers with the following text inside:

/var/lib/docker/containers/*/*.log {
    rotate 31
    daily
    nocompress
    missingok
    notifempty
    copytruncate
}

Optionally, you can replace nocompress to compress and change the number of days.

Out of the box

  • Ubuntu 14.04, 16.04 or 18.04 LTS
  • Nginx stable: 1.8, 1.10, 1.12, 1.14, 1.16 or dev: 1.9, 1.11, 1.13, 1.15, 1.17

License

Nginx docker image is open-sourced software licensed under the MIT license

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.