webdevops/php

The php images are based on webdevops/base-app with PHP cli and PHP-FPM. PHP-FPM is running on port 9000.

Uses Supervisord

This image is using supervisor and runs the daemon under user application (UID 1000; GID 1000) as default. If the container is started under a different user the daemon will be run under the specified uid.

Docker image tags

Tag Distribution name PHP Version
5.6 customized official php image PHP 5.6
7.0 customized official php image PHP 7.0
7.1 customized official php image PHP 7.1
alpine link to alpine-php7 PHP 7.x
alpine-php7   PHP 7.x
alpine-php5   PHP 5.6
alpine-3 deprecated PHP 5.6
alpine-3-php7 deprecated PHP 7.x
ubuntu-12.04 precise PHP 5.3
ubuntu-14.04 trusty (LTS) PHP 5.5
ubuntu-15.04 vivid PHP 5.6
ubuntu-15.10 wily PHP 5.6
ubuntu-16.04 xenial (LTS) PHP 7.0
debian-7 wheezy PHP 5.4
debian-8 jessie PHP 5.6
debian-8-php7 jessie with dotdeb PHP 7.x (via sury)
debian-9 stretch PHP 7.0
centos-7   PHP 5.4
centos-7-php56   PHP 5.6

Environment variables

Base environment variables

Environment variable Description Default
LOG_STDOUT Destination of daemon output empty (stdout)
LOG_STDERR Destination of daemon errors empty (stdout)
SERVICE_CRON_OPTS cron daemon arguments empty (when syslog is used)
SERVICE_DNSMASQ_OPTS dnsmasq daemon arguments empty (when syslog is used)
SERVICE_DNSMASQ_USER dnsmasq effective user root
SERVICE_POSTFIX_OPTS postfix daemon arguments empty (when syslog is used)
SERVICE_SSH_OPTS ssh daemon arguments empty (when syslog is used)
SERVICE_SUPERVISOR_OPTS supervisor daemon arguments empty (when syslog is used)
SERVICE_SUPERVISOR_USER supervisor effective user root
SERVICE_SYSLOG_OPTS syslog daemon arguments empty (when syslog is used)

Base environment variables

Environment variable Description Default
POSTFIX_MYNETWORKS Postfix mynetworks address empty
POSTFIX_RELAYHOST Postfix upstream relay server empty

PHP.ini variables

You can specify eg. php.memory_limit=256M as dyanmic env variable which will sets memory_limit = 256M as php setting.

Environment variable Description Default
php.{setting-key} Sets the {setting-key} as php setting  
PHP_DATE_TIMEZONE date.timezone UTC
PHP_DISPLAY_ERRORS display_errors 0
PHP_MEMORY_LIMIT memory_limit 512M
PHP_MAX_EXECUTION_TIME max_execution_time 300
PHP_POST_MAX_SIZE post_max_size 50M
PHP_UPLOAD_MAX_FILESIZE upload_max_filesize 50M
PHP_OPCACHE_MEMORY_CONSUMPTION opcache.memory_consumption 256
PHP_OPCACHE_MAX_ACCELERATED_FILES opcache.max_accelerated_files 7963
PHP_OPCACHE_VALIDATE_TIMESTAMPS opcache.validate_timestamps default
PHP_OPCACHE_REVALIDATE_FREQ opcache.revalidate_freq default
PHP_OPCACHE_INTERNED_STRINGS_BUFFER opcache.interned_strings_buffer 16

PHP FPM variables

You can specify eg. fpm.pool.pm.max_requests=1000 as dyanmic env variable which will sets pm.max_requests = 1000 as fpm pool setting. The prefix fpm.pool is for pool settings and fpm.global for global master process settings.

Environment variable Description Default
fpm.global.{setting-key} Sets the {setting-key} as fpm global setting for the master process  
fpm.pool.{setting-key} Sets the {setting-key} as fpm pool setting  
FPM_PROCESS_MAX process.max distribution default
FPM_PM_MAX_CHILDREN pm.max_children distribution default
FPM_PM_START_SERVERS pm.start_servers distribution default
FPM_PM_MIN_SPARE_SERVERS pm.min_spare_servers distribution default
FPM_PM_MAX_SPARE_SERVERS pm.max_spare_servers distribution default
FPM_PROCESS_IDLE_TIMEOUT pm.process_idle_timeout distribution default
FPM_MAX_REQUESTS pm.max_requests distribution default
FPM_REQUEST_TERMINATE_TIMEOUT request_terminate_timeout distribution default
FPM_RLIMIT_FILES rlimit_files distribution default
FPM_RLIMIT_CORE rlimit_core distribution default

Customization

PHP customization

For customization a placeholder /opt/docker/etc/php/php.ini is available which will be loaded as last configuration file. All settings can be overwritten in this ini file.

Either use COPY inside your Dockerfile to overwrite this file or use RUN echo memory_limit = 128 M >> /opt/docker/etc/php/php.ini to set specific php.ini values.

Docker image layout

PHP layout

File/Directory Description
/opt/docker/etc/php/php.webdevops.ini PHP settings from WebDevOps image
/opt/docker/etc/php/php.ini badge-customization php.ini for custom settings
/opt/docker/etc/php/fpm/php-fpm.conf PHP-FPM main configuration file
/opt/docker/etc/php/fpm/pool.d/application.conf Application PHP-FPM pool configuration file
/opt/docker/etc/supervisor.d/php-fpm.conf Supervisord configuration file for PHP-FPM