A docker image with included PHP, Compser, Crontab and Supervisord based on official PHP images
10K+
Docker images with cron, composer and supervisor included 💪 Check out project documentation on GitHub.
This image is provided with several additional tools for managing PHP extensions. These tools allows you to easily enable or disable PHP extensions and change their configuration even on running containers:
docker-pcs-php-ext-config: allows to edit configuration of php extension. This script automatically finds
correct configuration file for given extension. This tool can be used for adding, modifying and removing
configuration values.
# Adding and modifying:
docker-pcs-php-ext-config opcache \
opcache.memory_consumption=512 \
opcache.interned_strings_buffer=8 \
opcache.max_accelerated_files=10000 \
opcache.revalidate_freq=0 \
opcache.fast_shutdown=1 \
opcache.enable_cli=1 \
opcache.enable=1
# Removing:
docker-pcs-php-ext-config opcache \
--rm opcache.memory_consumption \
--rm opcache.interned_strings_buffer
This tool can be also used for editing php.ini file:
touch /usr/local/etc/php/php.ini # make sure this php.ini file exists
docker-pcs-php-ext-config php --ini-name ../php.ini \
log_errors=On \
access_log=/dev/stdout \
error_log=/dev/stderr
Paths provided by the ini-name argument are relative to /usr/local/etc/php/conf.d/ directory.
On running containers you can also add --restart argument to automatically restart the PHP process.
docker-pcs-php-ext-enable and docker-pcs-php-ext-disable: similar to phpenmod and phpdismod. You
can also use --restart argument as in docker-pcs-php-ext-config script.
docker-pcs-php-ext-install: works similar to docker-php-ext-install but fallback to pecl if extension source
isn't provided with image. This script also automatically enables installed extensions.
docker-pcs-php-restart: restarts FPM or Apache process to reload configuration.
Detailed instruction how to install PHP extension you can find in official PHP docker images documentation.
For your local development, you can create a separate Dockerfile with preinstalled XDebug:
FROM mdobak/php-common-stack:fpm-alpine
# your configuration
RUN docker-pcs-php-ext-install xdebug \
&& docker-pcs-php-ext-config xdebug \
xdebug.remote_enable=1 \
xdebug.remote_autostart=1 \
xdebug.remote_host=172.17.0.1
#xdebug.remote_host=docker.for.mac.localhost
XDebug slows down PHP execution noticeably so most likely you won't want to keep it working on all the time.
Fortunately, you can easily enable and disable XDebug using docker-pcs-php-ext-enable and docker-pcs-php-ext-disable
commands described earlier. You can use these commands by logging into container's root shell or with docker exec
command, e.g: docker exec CONTAINER_NAME docker-pcs-php-ext-disable xdebug.
Alternatively, you can disable xdebug.remote_autostart and manage XDebug using cookies but this approach prevents you
from debugging cron and supervisor scripts.
More information about XDebug you can find in official documentation.
On Debian images a cron job can be defined in a crontab-like files in the /etc/cron.d/ directory or added within the
/etc/crontab file. On Alpine images you can use only crontab-like files in the /etc/crontab/ directory.
To add a program, you’ll need to add the supervisord configuration file. For Debian based images configuration files
should be stored in /etc/supervisor/conf.d/ directory and for Alpine based images in /etc/supervisor.d/. In both
of these directories is defined default supervisord.conf file so be careful to not overwrite it.
Simplest configuration file for supervisor can looks like this:
[program:my_app]
command = /var/www/html/bin/console my:worker
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0
More information about Supervisord you can find in official documentation.
This images are based on official PHP docker images and more details you can find their documentation.
Content type
Image
Digest
Size
60.7 MB
Last updated
over 5 years ago
docker pull mdobak/php-common-stack:8.1.0alpha1-cli-alpine