These image extends webdevops/php
with a nginx daemon which is running on port 80 and 443
Uses Supervisord
This image is using supervisor and runs the daemon under user application
(UID 1000; GID 1000) as default. If the container isstarted under a different user the daemon will be run under the specified uid.
3 - Re-build your PHP-FPM Container docker-compose build php-fpm. 4 - Check enabled locales with docker-compose exec php-fpm locale -a. Update the locale setting, default is POSIX. 1 - Open the.env file and set PHPFPMDEFAULTLOCALE to enUS.UTF8 or other locale you want. 2 - Re-build your PHP-FPM Container docker-compose build php-fpm. RUN rm -rf vendor && composer install FROM richarvey/nginx-php-fpm WORKDIR /var/www/html COPY -from=composer /app. This solution works and does not bloat the final image, but it is not ideal, because the vendor directory on the host is copied into the Docker context during the build process, which adds time. First, I need to install PHP and Composer to initiate the Symfony project. Sudo apt install php php-xml php-zip unzip. Php-xml and php-zip are requiert to install Symfony, unzip is recommended. Needs php and composer (or php composer.phar). Installing via Docker # Installing via Docker. The Docker community maintains WordPress and WP-CLI images.
Docker image tags¶
In this article, we will learn how to set up the Laravel development environment with Docker. We are going to use the Docker Compose to set up the development environment. Let’s start the steps without delay. This may also help: Laravel, Nginx and MySQL configuration with Docker Compose Video Tutorial Step 1 – Download Laravel Containerize your Laravel Application with Docker Compose.
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 |
7.2 | customized official php image | PHP 7.2 |
7.3 | customized official php image | PHP 7.3 |
7.4 | customized official php image | PHP 7.4 |
7.1-alpine | customized official php image | PHP 7.1 |
7.2-alpine | customized official php image | PHP 7.2 |
7.3-alpine | customized official php image | PHP 7.3 |
7.4-alpine | customized official php image | PHP 7.4 |
alpine | deprecated | PHP 7.x |
alpine-php7 | deprecated | PHP 7.x |
alpine-php5 | deprecated | PHP 5.6 |
alpine-3 | deprecated | PHP 5.6 |
alpine-3-php7 | deprecated | PHP 7.x |
ubuntu-12.04 | deprecated | PHP 5.3 |
ubuntu-14.04 | deprecated | PHP 5.5 |
ubuntu-15.04 | deprecated | PHP 5.6 |
ubuntu-15.10 | deprecated | PHP 5.6 |
ubuntu-16.04 | deprecated | PHP 7.0 |
debian-7 | deprecated | PHP 5.4 |
debian-8 | deprecated | PHP 5.6 |
debian-8-php7 | deprecated | PHP 7.x (via sury) |
debian-9 | deprecated | PHP 7.0 |
centos-7 | PHP 5.4 | |
centos-7-php56 | PHP 5.6 | |
centos-7-php7 | PHP 7.0 |
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 |
Web environment variables¶
Docker Composer Php Version
Environment variable | Description | Default |
---|---|---|
WEB_DOCUMENT_ROOT | Document root for webserver | /app |
WEB_DOCUMENT_INDEX | Index document | index.php |
WEB_ALIAS_DOMAIN | Domain aliases | *.vm |
WEB_PHP_SOCKET | PHP-FPM socket address | 127.0.0.1:9000 (for php-* images) |
SERVICE_PHPFPM_OPTS | PHP-FPM command arguments | empty (when php fpm is used) |
SERVICE_APACHE_OPTS | Apache command arguments | empty (when apache is used) |
SERVICE_NGINX_OPTS | Nginx command arguments | empty (when nginx is used) |
SERVICE_NGINX_CLIENT_MAX_BODY_SIZE | Nginx client_max_body_size | 50m (when nginx is used) |
PHP modules¶
As we build our images containing almost every PHP module and having it activated by default, you might want to deactivate some.
You can specify a comma-separated list of unwanted modules as dynamic env variable PHP_DISMOD
, e.g. PHP_DISMOD=ioncube,redis
.
PHP.ini variables¶
You can specify eg. php.memory_limit=256M
as dynamic env variable which will set 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 globalsetting for the master process | |
fpm.pool.{setting-key} | Sets the {setting-key} as fpm poolsetting | |
FPM_PROCESS_MAX | process.max | distributiondefault |
FPM_PM_MAX_CHILDREN | pm.max_children | distributiondefault |
FPM_PM_START_SERVERS | pm.start_servers | distributiondefault |
FPM_PM_MIN_SPARE_SERVERS | pm.min_spare_servers | distributiondefault |
FPM_PM_MAX_SPARE_SERVERS | pm.max_spare_servers | distributiondefault |
FPM_PROCESS_IDLE_TIMEOUT | pm.process_idle_timeout | distributiondefault |
FPM_MAX_REQUESTS | pm.max_requests | distributiondefault |
FPM_REQUEST_TERMINATE_TIMEOUT | request_terminate_timeout | distributiondefault |
FPM_RLIMIT_FILES | rlimit_files | distributiondefault |
FPM_RLIMIT_CORE | rlimit_core | distributiondefault |
Composer¶
Due to the incompatibilities between composer v1 and v2 we introduce a simple mechanism to switch between composer versions.
Environment variable | Description | Default |
---|---|---|
COMPOSER_VERSION | Specify the composer version to use | 2 |
Be aware that this switch is only executed during container start (entrypoint).If you want to build your software with a specific composer version, you can do this:
Or composer
respectively.
Customization¶
PHP customization¶
For customization a placeholder /opt/docker/etc/php/php.ini
is available which will be loaded as lastconfiguration file. All settings can be overwritten in this ini file.
Either use COPY
inside your Dockerfile
to overwrite this file or useRUNechomemory_limit=128M>>/opt/docker/etc/php/php.ini
to set specific php.ini values.
Nginx customization¶
This image has two directories for configuration files which will be automatic loaded.
Composer Php Dockerfile
For global configuration options the directory /opt/docker/etc/nginx/conf.d
can be used.For vhost configuration options the directory /opt/docker/etc/nginx/vhost.common.conf
can be used.
Composer Php Dockery
Any *.conf
files inside these direcories will be included either global or the vhost section.
Docker image layout¶
Nginx layout¶
File/Directory | Description |
/opt/docker/etc/nginx/conf.d | Main global configuration directory (automatically included files) |
/opt/docker/etc/nginx/conf.d/10-php.conf | PHP cgi configuration |
/opt/docker/etc/nginx/ssl | SSL configuration directory for certifications and keys |
/opt/docker/etc/nginx/ssl/server.crt | Example SSL certification (*.vm) |
/opt/docker/etc/nginx/ssl/server.csr | Example SSL certification request (*.vm) |
/opt/docker/etc/nginx/ssl/server.key | Example SSL key (*.vm) |
/opt/docker/etc/nginx/vhost.common.d | Vhost configuration directory (automatically included files) |
/opt/docker/etc/nginx/vhost.common.d/10-location-root.conf | Redirect requests to DOCUMENT_INDEX |
/opt/docker/etc/nginx/vhost.common.d/10-php.conf | PHP cgi configuration for vhost |
/opt/docker/etc/nginx/global.conf | Global nginx configuration |
/opt/docker/etc/nginx/main.conf | Main Nginx configuration |
/opt/docker/etc/nginx/php.conf | Deprecated PHP configuration |
/opt/docker/etc/nginx/vhost.common.conf | Deprecated vhost common include |
/opt/docker/etc/nginx/vhost.conf | Vhost configuration |
/opt/docker/etc/nginx/vhost.ssl.conf | Vhost SSL configuration |
/opt/docker/etc/supervisor.d/nginx.conf | Supervisord configuration file for Nginx |
PHP layout¶
File/Directory | Description |
/opt/docker/etc/php/php.webdevops.ini | PHP settings from WebDevOps image |
/opt/docker/etc/php/php.ini | 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 |