Skip to content

About

A set of PHP Docker images

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

854 stars

Watchers

27 watching

Forks

Latest commit

 

History

729 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker PHP Images GitHub workflow

General purpose PHP images for Docker

What's new

  • PHP 8.6: images for PHP 8.6, with all the extensions of the other versions except swoole.
  • Debugging, profiling, coverage: an interactive guide picks the tools for your needs (Xdebug, PCOV, Excimer, XHProf, SPX…) and gives the setup of your IDE and your AI agent. PHP_PROFILER profiles requests and commands on a trigger.
  • Documentation site: thecodingmachine.github.io/docker-images-php, in English and in French, with the tuning simulator and the reverse proxy guide.

This repository contains a set of developer-friendly, general purpose PHP images for Docker.

  • You can enable or disable the extensions using environment variables.
  • You can also modify the php.ini settings using environment variables.
  • 2 types available: slim (no extensions preloaded) or fat (most common PHP extensions are built-in)
  • 3 variants available: CLI, apache and fpm (with an optional built-in Apache, recommended for web applications)
  • Fat images are bundled with Supercronic which is a Cron compatible task runner. Cron jobs can be configured using environment variables
  • All images come with Composer installed
  • All variants can be installed with or without NodeJS (if you need to build your static assets).
  • Composer binaries (vendor/bin and global binaries) and NodeJS binaries (node_modules/.bin) can be run without their path, including with docker exec / docker compose exec (e.g. docker compose exec app phpstan)
  • Everything is done to limit file permission issues that often arise when using Docker. The image is actively tested on Linux, Windows and MacOS

See the documentation for all the features.

Images

The main images, for PHP 8.6:

Use Image
Web application: Apache + mod_php thecodingmachine/php:8.6-v5-apache
Web application: PHP-FPM (see the fpm variant) thecodingmachine/php:8.6-v5-fpm
CLI: scripts, workers, CI thecodingmachine/php:8.6-v5-cli
With NodeJS 24, to build your assets thecodingmachine/php:8.6-v5-apache-node24
Production (slim): only the extensions listed at build time thecodingmachine/php:8.6-v5-slim-apache

A tag reads <PHP version>-v5-[slim-]<variant>[-node<NodeJS version>], for PHP 8.6 to 8.1 and NodeJS 22, 24 and 26. In production, prefer the slim image: it contains only the extensions you list, so it is smaller and exposes less; the fat image is handy in development. The Images page builds the tag, the Dockerfile and the compose.yml for your use, and lists all the tags (also on GitHub).

Supported versions

We only maintain the PHP and NodeJS versions that are still supported by their respective communities (see PHP supported versions and NodeJS releases). Bugs are fixed on maintained versions only.

PHP version Status
8.6 Maintained (until 2030-12-31)
8.5 Maintained (until 2029-12-31)
8.4 Maintained (until 2028-12-31)
8.3 Maintained (until 2027-12-31)
8.2 Maintained (until 2026-12-31)
8.1 Not maintained (end of life: 2025-12-31)
8.0 Not maintained (end of life: 2023-11-26)
7.4 Not maintained (end of life: 2022-11-28)
NodeJS version Status
26 Maintained (until 2029-04-30)
24 Maintained (until 2028-04-30)
22 Maintained (until 2027-04-30)
20 Not maintained (end of life: 2026-04-30)

Images of non-maintained versions are still available but no longer receive fixes: use them at your own risk and plan your upgrade. Critical vulnerabilities may get an exceptional fix: php2shell (CVE-2026-109618 and CVE-2026-109619) is fixed in all the v5 images, not in the v4 ones. See Security.

Usage

The images are based on Ubuntu 24.04, with PHP from the Ondřej Surý's PHP repository.

Example with CLI:

$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.6-v5-cli php your-script.php

Example with PHP-FPM and its built-in Apache (in the same container), recommended to serve a web application:

$ docker run -p 80:80 --rm --name my-apache-fpm-app -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm

Example with PHP-FPM alone, behind your own web server:

$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm

Example with Apache and mod_php:

$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-apache

Example with Apache + Node 24.x in a Dockerfile:

Dockerfile

FROM thecodingmachine/php:8.6-v5-apache-node24

COPY src/ /var/www/html/
RUN composer install
RUN npm install
RUN npm run build

Documentation

The documentation is also on the documentation site, in English and in French.

Most features are configured with environment variables:

Topic Content Main variables
PHP extensions Extensions of the slim and fat images, enabling them, compiling them in a slim image PHP_EXTENSION_*, PHP_EXTENSIONS
PHP configuration Base php.ini file and php.ini parameters TEMPLATE_PHP_INI, PHP_INI_*
Variants cli, apache (document root, ports, modules, logs, user) and fpm (built-in Apache, PHP-FPM) APACHE_DOCUMENT_ROOT, APACHE_EXTENSION_*, APACHE_LOG_*, PHP_FPM_WEB_SERVER
Serving with the fpm variant Built-in Apache or your own web server, constraints of PHP-FPM, migration from apache PHP_FPM_WEB_SERVER, PHP_FPM_PM_*
Behind a reverse proxy Real IP of the users behind Traefik, nginx, Kubernetes or Cloudflare, without trusting forged headers APACHE_TRUSTED_PROXIES, APACHE_TRUSTED_CLOUDFLARE
Processes Startup commands, cron jobs and daemons run along with the main command STARTUP_COMMAND_*, CRON_*, DAEMON_*
Debugging, profiling, coverage The tools for your needs (Xdebug, PCOV, Excimer, XHProf, SPX, Blackfire, OpenTelemetry), the setup of your IDE and your AI agent PHP_EXTENSION_XDEBUG, PHP_PROFILER, XDEBUG_CLIENT_HOST
Advanced features Permissions, NodeJS, Composer version, locales, SSH keys, Kubernetes DOCKER_USER, COMPOSER_VERSION, LOCALES

The slim images install some tools during the build of your image with an ARG before the FROM: PHP_EXTENSIONS, INSTALL_CRON, INSTALL_LOCALES, NODE_VERSION and COMPOSER_VERSION.

Migrating from older image versions

Check the migration notes.

Roadmap

The v5 images keep receiving fixes and backward compatible features. The next major version, v6, is planned for 2027: Ubuntu 26.04, a FrankenPHP variant and much faster builds. Follow and discuss it in the roadmap issue.

Contributing

The Dockerfiles and this README are generated from the templates of the utils directory: see the contributing guide to edit, build and test the images.

Special thanks

These images have been strongly inspired by tetraweb/php.

About

A set of PHP Docker images

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

854 stars

Watchers

27 watching

Forks

Used by

Contributors

Languages