Public | Automated Build

Last pushed: 6 days ago
Short Description
Based on the official PHP 7-fpm image, added commonly used extensions and Composer.phar
Full Description

Php with extensions

Based on the official PHP 7-fpm image, added commonly used extensions and Composer.phar.

Intended to deploy a PHP stack and switch versions very fast, having configs stored in CVS with your application.

Here you can find the build script.

If you use Docker Machine in Windows or MacOS, mount the folder with your project to your virtual machine, using the same path. You can find how to do it on StackOverflow.

If you use docker in Linux, it is better to have the user and group ID inside the docker container synchronized with the user and group ID in your system. Check www-data id in your system, and add yourself to the www-data group.

$ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data)
$ sudo usermod -a -G www-data $(whoami)

The value 33 is hard-coded by the official image maintainers. It can be changed by extending the phpextensions image.


Assuming your document root folder is called wwroot\ and is located in your application folder.

  1. Init config and log folders, set the group ownership
  2. Init php configurations files from container
  3. Edit configs and disable unused extensions
  4. Preare a database initial dump file
  5. Run docker-compose
  6. Commit your configs to your project VCS


Init configs and logs folders

cd /path/to/application
wget -O - |tar -xz
chgrp -R www-data .
chmod g+rwx logs etc
docker run --rm -v $(pwd)/etc:/usr/local/etc grigori/phpextensions

Disable PHP extensions you don't want to have enabled
Edit PHP and NGINX configs

cd ./etc/php/conf.d/
rm docker-php-ext-xdebug.ini docker-php-ext-ev.ini docker-php-ext-imap.ini
cd ../../..
vi ./etc/php/php.ini
vi ./etc/nginx/conf.d/default.conf

Prepare a database init dump. Can be in plain sql or compressed with .gz. Should contain a create database command.
Add custom mysql setings.

vi ./etc/my.custom.cnf
mv myapp.dump.sql init.sql

Add Nginx/PHP/MySQL configs to your git repo.

git add ./etc ./docker-compose.yml && git commit -m "Adding php/nginx/mysql/docker-compose configs"

Prepare docker-compose config and start

docker-compose up

Extensions added to the FPM SAPI:

  • Apcu (beta)
  • Bcmath
  • Data Structures
  • Ev (beta)
  • GD with webp support
  • IMAP
  • igbinary (beta) - a serializer for redis and memcached
  • Kerberos
  • Mbstring
  • memcached (beta), configured as a session storage
  • Msgpack (beta), another nice serializer
  • mysqli
  • pdo_mysql
  • pdo_pgsql
  • Pgsql built upon Postgres 9 client lib
  • Redis (beta)
  • XSL
  • Xdebug (beta)
  • Zend OPcache

Additional extensions added to CLI version:

Additional disk consumption: 140 MB

REPOSITORY          TAG                 SIZE
phpextensions       latest              635.3 MB
php                 7-fpm               495 MB
Docker Pull Command
Source Repository

Comments (0)