diff --git a/README.md b/README.md index 78d06eb3..0b9619e3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,507 @@ -# Docker PHP-FPM images +# PHP-FPM Docker images -

Options

+[![Build Status](https://travis-ci.org/devilbox/docker-php-fpm.svg?branch=master)](https://travis-ci.org/devilbox/docker-php-fpm) +[![Join the chat at https://gitter.im/devilbox/Lobby](https://badges.gitter.im/devilbox/Lobby.svg)](https://gitter.im/devilbox/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![](https://images.microbadger.com/badges/license/devilbox/php-fpm.svg)](https://microbadger.com/images/devilbox/php-fpm "php-fpm") +[![Github](https://img.shields.io/badge/github-docker--php--fpm-red.svg)](https://github.com/devilbox/docker-php-fpm) -### Environment variables +**[devilbox/docker-php-fpm](https://github.com/devilbox/docker-php-fpm)** -Have a look at the following table to see all supported environment variables for each Docker image flavour. +This repository will provide you fully functional PHP-FPM Docker images in different flavours, +versions and packed with different types of integrated PHP modules. It also solves the problem of [syncronizing file permissions](#unsynchronized-permissions) of mounted volumes between the host and the container. + +| Docker Hub | Upstream Project | +|------------|------------------| +| | | + +--- + +#### Table of Contents + +1. **[Motivation](#motivation)** + 1. [Unsynchronized permissions](#unsynchronized-permissions) + 2. [It gets even worse](#it-gets-even-worse) + 3. [The solution](#the-solution) +2. **[PHP-FPM Flavours](#php-fpm-flavours)** + 1. [Assembly](#assembly) + 2. [Available Images](#available-images) + 3. [Tagging](#tagging) + 4. [PHP Modules](#php-modules) +3. **[PHP-FPM Features](#php-fpm-features)** + 1. [Image: base](#image-base) + 2. [Image: mods](#image-mods) + 3. [Image: prod](#image-prod) + 4. [Image: work](#image-work) +4. **[PHP-FPM Options](#php-fpm-options)** + 1. [Environment variables](#environment-variables) + 2. [Volumes](#volumes) + 3. [Ports](#ports) +5. **[Integrated Development Environment](#integrated-development-environment)** + 1. [What toos can you expect](#what-tools-can-you-expect) + 2. [What else is available](#what-else-is-available) +6. **[Examples](#examples)** + 1. [Provide PHP-FPM port to host](#provide-php-fpm-port-to-host) + 2. [Alter PHP-FPM and system timezone](#alter-php-fpm-and-system-timezone) + 3. [Load custom PHP configuration](#load-custom-php-configuration) + 4. [Load custom PHP modules](#load-custom-php-modules) + 5. [MySQL connect via 127.0.0.1 (via port-forward)](#mysql-connect-via-127-0-0-1-via-port-forward-) + 6. [MySQL and Redis connect via 127.0.0.1 (via port-forward)](#mysql-and-redis-connect-via-127-0-0-1-via-port-forward-) + 7. [Launch Postfix for mail-catching](#launch-postfix-for-mail-catching) + 8. [Webserver and PHP-FPM](#webserver-and-php-fpm) + 9. [Create MySQL Backups](#create-mysql-backups) +7. **[Automated builds](#automated-builds)** +8. **[Contributing](#contributing)** +9. **[Credits](#credits)** +10. **[License](#license)** + +---- + +

Motivation

+ +One main problem with a running Docker container is to **synchronize the ownership of files in a mounted volume** in order to preserve security (Not having to use `chmod 0777`). + + +#### Unsynchronized permissions + +Consider the following directory structure of a mounted volume. Your hosts computer uid/gid are `1000` which does not have a corresponding user/group within the container. Fortunately the `tmp/` directory allows everybody to create new files in it. + +```shell + [Host] | [Container] +------------------------------------------------------------------------------------------ + $ ls -l | $ ls -l + -rw-r--r-- user group index.php | -rw-r--r-- 1000 1000 index.php + drwxrwxrwx user group tmp/ | drwxrwxrwx 1000 1000 tmp/ +``` + +Your web application might now have created some temporary files (via the PHP-FPM process) inside the `tmp/` directory: + +```shell + [Host] | [Container] +------------------------------------------------------------------------------------------ + $ ls -l tmp/ | $ ls -l tmp/ + -rw-r--r-- 96 96 _tmp_cache01.php | -rw-r--r-- www www _tmp_cache01.php + -rw-r--r-- 96 96 _tmp_cache02.php | -rw-r--r-- www www _tmp_cache01.php +``` + +On the Docker container side everything is still fine, but on your host computers side, those files now show a user id and group id of `96`, which is in fact the uid/gid of the PHP-FPM process running inside the container. On the host side you will now have to use `sudo` in order to delete/edit those files. + +#### It gets even worse + +Consider your had created the `tmp/` directory on your host only with `0775` permissions: + +```shell + [Host] | [Container] +------------------------------------------------------------------------------------------ + $ ls -l | $ ls -l + -rw-r--r-- user group index.php | -rw-r--r-- 1000 1000 index.php + drwxrwxr-x user group tmp/ | drwxrwxr-x 1000 1000 tmp/ +``` + +If your web application now wants to create some temporary files (via the PHP-FPM process) inside the `tmp/` directory, it will fail due to lacking permissions. + +#### The solution + +To overcome this problem, it must be made sure that the PHP-FPM process inside the container runs under the same uid/gid as your local user that mouns the volumes and also wants to work on those files locally. However, you never know during Image build time what user id this would be. Therefore it must be something that can be changed during startup of the container. + +This is achieved by two environment variables that can be provided during startup in order to change the uid/gid of the PHP-FPM user prior starting up PHP-FPM. + +```shell +$ docker run -e NEW_UID=1000 -e NEW_GID=1000 -it devilbox/php-fpm:7.2-base +[INFO] Changing user 'devilbox' uid to: 1000 +root $ usermod -u 1000 devilbox +[INFO] Changing group 'devilbox' gid to: 1000 +root $ groupmod -g 1000 devilbox +[INFO] Starting PHP 7.2.0 (fpm-fcgi) (built: Oct 30 2017 12:05:19) +``` + +When **`NEW_UID`** and **`NEW_GID`** are provided to the startup command, the container will do a `usermod` and `groupmod` prior starting up in order to assign new uid/gid to the PHP-FPM user. When the PHP-FPM process finally starts up it actually runs with your local system user and making sure permissions will be in sync from now on. + +At a minimum those two environment variables are offered by all flavours and types of the here provided PHP-FPM images. + +**Note:** + +To tackle this on the PHP-FPM side is only half a solution to the problem. The same applies to a web server Docker container when you offer **file uploads**. They will be uploaded and created by the web servers uid/gid. Therefore the web server itself must also provide the same kind of solution. See the following Web server Docker images for how this is done: + +**[Apache 2.2](https://github.com/devilbox/docker-apache-2.2)** | +**[Apache 2.4](https://github.com/devilbox/docker-apache-2.4)** | +**[Nginx stable](https://github.com/devilbox/docker-nginx-stable)** | +**[Nginx mainline](https://github.com/devilbox/docker-nginx-mainline)** + + +

PHP-FPM Flavours

+ +#### Assembly + +The provided Docker images heavily rely on inheritance to guarantee smallest possible image size. Each of them provide a working PHP-FPM server and you must decide what version works best for you. Look at the sketch below to get an overview about the two provided flavours and each of their different types. + +```shell + [PHP] # Base FROM image (Official PHP-FPM image) + ^ # + | # + | # + [base] # Introduces env variables and adjusts entrypoint + ^ # + | # + | # + [mods] # Installs additional PHP modules + ^ # via pecl, git and other means + | # + | # + [prod] # Devilbox flavour for production + ^ # (locales, postifx, socat and injectables) + | # (custom modules and *.ini files) + | # + [work] # Devilbox flavour for local development + # (includes backup and development tools) + # (sudo, custom bash and tool configs) +``` + +#### Available Images + +The following table shows a more complete overview about the offered Docker images and what they should be used for. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeDocker ImageDescription
basedevilbox/php-fpm:5.4-base + + +
devilbox/php-fpm:5.5-base + + +
devilbox/php-fpm:5.6-base + + +
devilbox/php-fpm:7.0-base + + +
devilbox/php-fpm:7.1-base + + +
devilbox/php-fpm:7.2-base + + +
modsdevilbox/php-fpm:5.4-mods + + +
devilbox/php-fpm:5.5-mods + + +
devilbox/php-fpm:5.6-mods + + +
devilbox/php-fpm:7.0-mods + + +
devilbox/php-fpm:7.1-mods + + +
devilbox/php-fpm:7.2-mods + + +
proddevilbox/php-fpm:5.4-prod + + +
devilbox/php-fpm:5.5-prod + + +
devilbox/php-fpm:5.6-prod + + +
devilbox/php-fpm:7.0-prod + + +
devilbox/php-fpm:7.1-prod + + +
devilbox/php-fpm:7.2-prod + + +
workdevilbox/php-fpm:5.4-work + + +
devilbox/php-fpm:5.5-work + + +
devilbox/php-fpm:5.6-work + + +
devilbox/php-fpm:7.0-work + + +
devilbox/php-fpm:7.1-work + + +
devilbox/php-fpm:7.2-work + + +
+ + +#### Tagging + +This repository uses Docker tags to refer to different flavours and types of the PHP-FPM Docker image. Therefore `:latest` and `:` as well as `:` must be presented differently. Refer to the following table to see how tagged Docker images are produced at Docker hub: + + + + + + + + + + + + + + + + + + + + + + + + + + +
Meant TagActual TagComment
:latest + :X.Y-base
+ :X.Y-mods
+ :X.Y-prod
+ :X.Y-work
+
Stable
(rolling)

These tags are produced by the master branch of this repository.
:<git-tag-name> + :X.Y-base-<git-tag-name>
+ :X.Y-mods-<git-tag-name>
+ :X.Y-prod-<git-tag-name>
+ :X.Y-work-<git-tag-name>
+
Stable
(fixed)

Every git tag will produce and preserve these Docker tags.
:<git-branch-name> + :X.Y-base-<git-branch-name>
+ :X.Y-mods-<git-branch-name>
+ :X.Y-prod-<git-branch-name>
+ :X.Y-work-<git-branch-name>
+
Feature
(for testing)

Tags produced by unmerged branches. Do not rely on them as they might come and go.
+ + +#### PHP Modules + +Check out this table to see which Docker image provides what PHP modules. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
basemods, prod and work
5.4Core, ctype, curl, date, dom, ereg, fileinfo, filter, hash, iconv, json, libxml, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, recode, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongo, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib
5.5Core, ctype, curl, date, dom, ereg, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongo, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib
5.6Core, ctype, curl, date, dom, ereg, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongo, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib
7.0Core, ctype, curl, date, dom, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib
7.1Core, ctype, curl, date, dom, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib
7.2Core, ctype, curl, date, dom, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, sodium, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, sodium, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlib
+ + + +

PHP-FPM Features

+ +#### Image: base +```shell +docker pull devilbox/php-fpm:5.4-base +docker pull devilbox/php-fpm:5.5-base +docker pull devilbox/php-fpm:5.6-base +docker pull devilbox/php-fpm:7.0-base +docker pull devilbox/php-fpm:7.1-base +docker pull devilbox/php-fpm:7.2-base +``` + +Generic PHP-FPM base image. Use it to derive your own php-fpm docker image from it and add more extensions, tools and injectables.

(Does not offer any environment variables except for `NEW_UID` and `NEW_GID`) + +#### Image: mods +```shell +docker pull devilbox/php-fpm:5.4-mods +docker pull devilbox/php-fpm:5.5-mods +docker pull devilbox/php-fpm:5.6-mods +docker pull devilbox/php-fpm:7.0-mods +docker pull devilbox/php-fpm:7.1-mods +docker pull devilbox/php-fpm:7.2-mods +``` + +Generic PHP-FPM image with fully loaded extensions. Use it to derive your own php-fpm docker image from it and add more extensions, tools and injectables.

(Does not offer any environment variables except for `NEW_UID` and `NEW_GID`) + +#### Image: prod +```shell +docker pull devilbox/php-fpm:5.4-prod +docker pull devilbox/php-fpm:5.5-prod +docker pull devilbox/php-fpm:5.6-prod +docker pull devilbox/php-fpm:7.0-prod +docker pull devilbox/php-fpm:7.1-prod +docker pull devilbox/php-fpm:7.2-prod +``` + +Devilbox production image. This Docker image comes with many injectables, port-forwardings, mail-catch-all and user/group rewriting. + +#### Image: work +```shell +docker pull devilbox/php-fpm:5.4-work +docker pull devilbox/php-fpm:5.5-work +docker pull devilbox/php-fpm:5.6-work +docker pull devilbox/php-fpm:7.0-work +docker pull devilbox/php-fpm:7.1-work +docker pull devilbox/php-fpm:7.2-work +``` + +Devilbox development image. Same as prod, but comes with lots of locally installed tools to make development inside the container as convenient as possible. See [Integrated Development Environment](#integrated-development-environment) for more information about this. + + + +

PHP-FPM Options

+ +#### Environment variables + +Have a look at the following table to see all supported environment variables for each Docker image flavour. @@ -89,7 +585,7 @@ Have a look at the following table to see all supported environment variables fo
-### Volumes +#### Volumes Have a look at the following table to see all offered volumes for each Docker image flavour. @@ -97,7 +593,7 @@ Have a look at the following table to see all offered volumes for each Docker im Image - Volumes + Volumes Description @@ -139,7 +635,7 @@ Have a look at the following table to see all offered volumes for each Docker im -### Ports +#### Ports Have a look at the following table to see all offered exposed ports for each Docker image flavour. @@ -162,47 +658,292 @@ Have a look at the following table to see all offered exposed ports for each Doc +

Integrated Development Environment

+ +If you plan to use the PHP-FPM image for development, hence being able to execute common commands inside the container itself, you should go with the **work** Image. -

Modules

+The **work** Docker image has many common tools already installed which on one hand increases its image size, but on the other hand removes the necessity to install those tools locally. + +You want to use tools such as `git`, `drush`, `composer`, `npm`, `eslint`, `phpcs` as well as many others, simply do it directly inside the container. As all Docker images are auto-built every night by travis-ci it is assured that you are always at the latest version of your favorite dev tool. + + +#### What tools can you expect - - - + + - - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
basemods, prod and workToolDescription
5.4Core, ctype, curl, date, dom, ereg, fileinfo, filter, hash, iconv, json, libxml, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, recode, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongo, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlibawesome-ciVarious linting and source code analyzing tools.
5.5Core, ctype, curl, date, dom, ereg, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongo, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlibcomposerDependency Manager for PHP.
5.6Core, ctype, curl, date, dom, ereg, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apc, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongo, mongodb, msgpack, mysql, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlibdrupal-consoleThe Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
7.0Core, ctype, curl, date, dom, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlibdrushDrush is a computer software shell-based application used to control, manipulate, and administer Drupal websites.
7.1Core, ctype, curl, date, dom, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlibeslintThe pluggable linting utility for JavaScript and JSX.
7.2Core, ctype, curl, date, dom, fileinfo, filter, ftp, hash, iconv, json, libxml, mbstring, mysqlnd, openssl, pcre, PDO, pdo_sqlite, Phar, posix, readline, Reflection, session, SimpleXML, sodium, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter, zlibamqp, apcu, bcmath, bz2, calendar, Core, ctype, curl, date, dba, dom, enchant, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, igbinary, imagick, imap, interbase, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, pspell, readline, recode, redis, Reflection, session, shmop, SimpleXML, snmp, soap, sockets, sodium, SPL, sqlite3, standard, swoole, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, uploadprogress, wddx, xdebug, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zip, zlibgitGit is a version control system for tracking changes in source files.
git-flowGit-flow tools.
gulpGulp command line JS tool.
gruntGrunt command line JS tool.
jsonlintJson command line linter.
laravel installerA CLI tool to easily install and manage the laravel framework.
linuxbrewThe Homebrew package manager for Linux.
mdlMarkdown command line linter.
mdlintMarkdown command line linter.
mysqldump-secureSecury MySQL database backup tool with encryption.
nodejsNode.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side.
npmnpm is a package manager for the JavaScript programming language.
phalcon-devtoolsCLI tool to generate code helping to develop faster and easy applications that use with Phalcon framework.
phpcsPHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
phpcbfPHP Code Beautifier and Fixer.
sassSass CSS compiler.
scss-lintSass/CSS command line linter.
symfony installerThis is the official installer to start new projects based on the Symfony full-stack framework.
tigText-mode Interface for Git.
webpackA bundler for javascript and friends.
wp-cliWP-CLI is the command-line interface for WordPress.
yamllintYaml command line linter.
yarnFast, reliable and secure dependency management.
+ + +#### What else is available + +Apart from the provided tools, you will also be able to use the container similar as you would do with your host system. Just a few things to mention here: + +* Mount custom bash configuration files so your config persists between restarts +* Use password-less `sudo` to become root and do whatever you need to do + +If there is anything else you'd like to be able to do, drop me an issue. + + +

Examples

+ +#### Provide PHP-FPM port to host +```shell +$ docker run -d \ + -p 127.0.0.1:9000:9000 \ + -t devilbox/php-fpm:7.2-prod +``` + +#### Alter PHP-FPM and system timezone +```shell +$ docker run -d \ + -p 127.0.0.1:9000:9000 \ + -e TIMEZONE=Europe/Berlin \ + -t devilbox/php-fpm:7.2-prod +``` + +#### Load custom PHP configuration + +`config/` is a local directory that will hold the PHP *.ini files you want to load into the Docker container. +```shell +# Create config directory to be mounted with dummy configuration +$ mkdir config +$ echo "xdebug.enable = 1" > config/xdebug.ini + +# Run container and mount it +$ docker run -d \ + -p 127.0.0.1:9000:9000 \ + -v config:/etc/php-custom.d \ + -t devilbox/php-fpm:7.2-prod +``` + +#### Load custom PHP modules + +`modules/` is a local directory that will hold the PHP modules you want to mount into the Docker container. `config/` is a local directory that will hold the PHP *.ini files you want to load into the Docker container. + +```shell +# Create module directory and place module into it +$ mkdir modules +$ cp /my/module/phalcon.so modules/ + +# Custom php config to load this module +$ mkdir config +$ echo "extension=/etc/php-modules.d/phalcon.so" > config/phalcon.ini + +# Run container and mount it +$ docker run -d \ + -p 127.0.0.1:9000:9000 \ + -v config:/etc/php-custom.d \ + -v modules:/etc/php-modules.d \ + -t devilbox/php-fpm:7.2-prod +``` + +#### MySQL connect via 127.0.0.1 (via port-forward) + +Forward MySQL Port from `172.168.0.30` (or any other IP address/hostname) and Port `3306` to the PHP docker on `127.0.0.1:3306`. By this, your PHP files inside the docker can use `127.0.0.1` to connect to a MySQL database. +```shell +$ docker run -d \ + -p 127.0.0.1:9000:9000 \ + -e FORWARD_PORTS_TO_LOCALHOST='3306:172.168.0.30:3306' \ + -t devilbox/php-fpm:7.2-prod +``` + +#### MySQL and Redis connect via 127.0.0.1 (via port-forward) + +Forward MySQL Port from `172.168.0.30:3306` and Redis port from `redis:6379` to the PHP docker on `127.0.0.1:3306` and `127.0.0.1:6379`. By this, your PHP files inside the docker can use `127.0.0.1` to connect to a MySQL or Redis database. +```shell +$ docker run -d \ + -p 127.0.0.1:9000:9000 \ + -e FORWARD_PORTS_TO_LOCALHOST='3306:172.168.0.30:3306, 6379:redis:6379' \ + -t devilbox/php-fpm:7.2-prod +``` + +#### Launch Postfix for mail-catching + +Once you set `$ENABLE_MAIL=1`, all mails sent via any of your PHP applications no matter to which domain, are catched locally into the `devilbox` account. You can also mount the mail directory locally to hook in with mutt and read those mails. +```shell +$ docker run -d \ + -p 127.0.0.1:9000:9000 \ + -v /tmp/mail:/var/mail \ + -e ENABLE_MAIL=1 \ + -t devilbox/php-fpm:7.2-prod +``` + +#### Webserver and PHP-FPM + +`~/my-host-www` will be the directory that serves the php files (your document root). Make sure to mount it into both, php and the webserver. +```shell +# Start PHP-FPM container +$ docker run -d \ + -v ~/my-host-www:/var/www/default/htdocs \ + --name php \ + -t devilbox/php-fpm:7.2-prod + +# Start webserver and link with PHP-FPM +$ docker run -d \ + -p 80:80 \ + -v ~/my-host-www:/var/www/default/htdocs \ + -e PHP_FPM_ENABLE=1 \ + -e PHP_FPM_SERVER_ADDR=php \ + -e PHP_FPM_SERVER_PORT=9000 \ + --link php \ + -t devilbox/nginx-mainline +``` + +#### Create MySQL Backups + +**Note:** This will only work with `work` Docker images. + +The MySQL server could be another Docker container linked to the PHP-FPM container. Let's assume the PHP-FPM container is able to access the MySQL container by the hostname `mysql`. + +``` +# Start container +$ docker run -d \ + -e MYSQL_BACKUP_USER=root \ + -e MYSQL_BACKUP_PASS=somepass \ + -e MYSQL_BACKUP_HOST=mysql \ + -v ~/backups:/shared/backsup \ + --name php \ + -t devilbox/php-fpm:7.2-work + +# Run database dump +$ docker exec -it php mysqldump-secure +``` + +

Automated builds

+ +[![Build Status](https://travis-ci.org/devilbox/docker-php-fpm.svg?branch=master)](https://travis-ci.org/devilbox/docker-php-fpm) + +Docker images are built and tested every night by **[travis-ci](https://travis-ci.org/devilbox/docker-php-fpm)** and pushed to **[Docker hub](https://hub.docker.com/r/devilbox/php-fpm/)** on success. This is all done automatically to ensure that sources as well as base images are always fresh and in case of security updates always have the latest patches. + +

Contributing

+ +Contributors are welcome. Feel free to star and clone this repository and submit issues and pull-requests. Add examples and show what you have created with the provided images. If you see any errors or ways to improve this repository in any way, please do so. + +

Credits

+ +* **[cytopia](https://github.com/cytopia)** + +

License

+ +**[MIT License](LICENSE.md)** + +Copyright (c) 2017 [cytopia](https://github.com/cytopia)