GithubHelp home page GithubHelp logo

0x15f / docker-nginx-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from romeoz/docker-nginx-php

0.0 2.0 0.0 57 KB

Nginx + PHP-FPM container image which can be linked to other containers.

License: MIT License

Dockerfile 80.74% PHP 1.31% Shell 17.95%

docker-nginx-php's Introduction

Docker Pulls

Table of Contents

Installation

docker pull romeoz/docker-nginx-php

or other versions (7.2, 7.1, 7.0, 5.6, 5.5, 5.4 or 5.3):

docker pull romeoz/docker-nginx-php:5.4

Alternately you can build the image yourself.

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

Quick Start

Run the application container:

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

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

Development/Persistence

For development a volume should be mounted at /var/www/app/.

The updated run command looks like this.

docker run --name app -d -p 8080:80 \
  -v /host/to/path/app:/var/www/app/ \
  romeoz/docker-nginx-php

This will make the development.

Linked to other container

As an example, will link with RDBMS PostgreSQL.

docker network create pg_net

docker run --name db -d --net pg_net romeoz/docker-postgresql

Run the application container:

docker run --name app -d -p 8080:80 \
  --net pg_net \
  -v /host/to/path/app:/var/www/app/ \
  romeoz/docker-nginx-php

Adding PHP-extension

You can use one of two choices to install the required php-extensions:

  1. docker exec -it app bash -c 'apt-get update && apt-get install php-mongo && rm -rf /var/lib/apt/lists/*'

  2. Create your container on based the current. Сontents Dockerfile:

FROM romeoz/docker-nginx-php:5.6

RUN apt-get update \
    && apt-get install -y php-mongo \
    && rm -rf /var/lib/apt/lists/* 

WORKDIR /var/www/app/

EXPOSE 80 443

CMD ["/usr/bin/supervisord"]

Next step,

docker build -t php-5.6 .
docker run --name app -d -p 8080:80 php-5.6

See installed php-extension: docker exec -it app php -m

Logging

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

docker logs 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 app > stdout.log 2>stderr.log
cat stdout.log
cat stderr.log

or split stdout and error to host stdout:

docker logs app > -
docker logs app 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 12.04, 14.04 or 16.04 LTS
  • Nginx 1.14
  • PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1 or 7.2
  • Composer (package manager)

Environment depends on the version of PHP.

License

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

docker-nginx-php's People

Contributors

0x15f avatar romeoz avatar

Watchers

 avatar  avatar

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.