Skip to content

About

A set of PHP Docker images

Topics

Resources

Code of conduct

Contributing

Stars

851 stars

Watchers

29 watching

Forks

Latest commit

 

History

625 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

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
  • 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

Name PHP version type variant NodeJS version Size
thecodingmachine/php:8.5-v5-apache 8.5.x fat apache N/A
thecodingmachine/php:8.5-v5-apache-node22 8.5.x fat apache 22.x
thecodingmachine/php:8.5-v5-apache-node24 8.5.x fat apache 24.x
thecodingmachine/php:8.5-v5-apache-node26 8.5.x fat apache 26.x
thecodingmachine/php:8.5-v5-fpm 8.5.x fat fpm N/A
thecodingmachine/php:8.5-v5-fpm-node22 8.5.x fat fpm 22.x
thecodingmachine/php:8.5-v5-fpm-node24 8.5.x fat fpm 24.x
thecodingmachine/php:8.5-v5-fpm-node26 8.5.x fat fpm 26.x
thecodingmachine/php:8.5-v5-cli 8.5.x fat cli N/A
thecodingmachine/php:8.5-v5-cli-node22 8.5.x fat cli 22.x
thecodingmachine/php:8.5-v5-cli-node24 8.5.x fat cli 24.x
thecodingmachine/php:8.5-v5-cli-node26 8.5.x fat cli 26.x
thecodingmachine/php:8.5-v5-slim-apache 8.5.x slim apache N/A
thecodingmachine/php:8.5-v5-slim-fpm 8.5.x slim fpm N/A
thecodingmachine/php:8.5-v5-slim-cli 8.5.x slim cli N/A
thecodingmachine/php:8.4-v5-apache 8.4.x fat apache N/A
thecodingmachine/php:8.4-v5-apache-node22 8.4.x fat apache 22.x
thecodingmachine/php:8.4-v5-apache-node24 8.4.x fat apache 24.x
thecodingmachine/php:8.4-v5-apache-node26 8.4.x fat apache 26.x
thecodingmachine/php:8.4-v5-fpm 8.4.x fat fpm N/A
thecodingmachine/php:8.4-v5-fpm-node22 8.4.x fat fpm 22.x
thecodingmachine/php:8.4-v5-fpm-node24 8.4.x fat fpm 24.x
thecodingmachine/php:8.4-v5-fpm-node26 8.4.x fat fpm 26.x
thecodingmachine/php:8.4-v5-cli 8.4.x fat cli N/A
thecodingmachine/php:8.4-v5-cli-node22 8.4.x fat cli 22.x
thecodingmachine/php:8.4-v5-cli-node24 8.4.x fat cli 24.x
thecodingmachine/php:8.4-v5-cli-node26 8.4.x fat cli 26.x
thecodingmachine/php:8.4-v5-slim-apache 8.4.x slim apache N/A
thecodingmachine/php:8.4-v5-slim-fpm 8.4.x slim fpm N/A
thecodingmachine/php:8.4-v5-slim-cli 8.4.x slim cli N/A
thecodingmachine/php:8.3-v5-apache 8.3.x fat apache N/A
thecodingmachine/php:8.3-v5-apache-node22 8.3.x fat apache 22.x
thecodingmachine/php:8.3-v5-apache-node24 8.3.x fat apache 24.x
thecodingmachine/php:8.3-v5-apache-node26 8.3.x fat apache 26.x
thecodingmachine/php:8.3-v5-fpm 8.3.x fat fpm N/A
thecodingmachine/php:8.3-v5-fpm-node22 8.3.x fat fpm 22.x
thecodingmachine/php:8.3-v5-fpm-node24 8.3.x fat fpm 24.x
thecodingmachine/php:8.3-v5-fpm-node26 8.3.x fat fpm 26.x
thecodingmachine/php:8.3-v5-cli 8.3.x fat cli N/A
thecodingmachine/php:8.3-v5-cli-node22 8.3.x fat cli 22.x
thecodingmachine/php:8.3-v5-cli-node24 8.3.x fat cli 24.x
thecodingmachine/php:8.3-v5-cli-node26 8.3.x fat cli 26.x
thecodingmachine/php:8.3-v5-slim-apache 8.3.x slim apache N/A
thecodingmachine/php:8.3-v5-slim-fpm 8.3.x slim fpm N/A
thecodingmachine/php:8.3-v5-slim-cli 8.3.x slim cli N/A
thecodingmachine/php:8.2-v5-apache 8.2.x fat apache N/A
thecodingmachine/php:8.2-v5-apache-node22 8.2.x fat apache 22.x
thecodingmachine/php:8.2-v5-apache-node24 8.2.x fat apache 24.x
thecodingmachine/php:8.2-v5-apache-node26 8.2.x fat apache 26.x
thecodingmachine/php:8.2-v5-fpm 8.2.x fat fpm N/A
thecodingmachine/php:8.2-v5-fpm-node22 8.2.x fat fpm 22.x
thecodingmachine/php:8.2-v5-fpm-node24 8.2.x fat fpm 24.x
thecodingmachine/php:8.2-v5-fpm-node26 8.2.x fat fpm 26.x
thecodingmachine/php:8.2-v5-cli 8.2.x fat cli N/A
thecodingmachine/php:8.2-v5-cli-node22 8.2.x fat cli 22.x
thecodingmachine/php:8.2-v5-cli-node24 8.2.x fat cli 24.x
thecodingmachine/php:8.2-v5-cli-node26 8.2.x fat cli 26.x
thecodingmachine/php:8.2-v5-slim-apache 8.2.x slim apache N/A
thecodingmachine/php:8.2-v5-slim-fpm 8.2.x slim fpm N/A
thecodingmachine/php:8.2-v5-slim-cli 8.2.x slim cli N/A
thecodingmachine/php:8.1-v5-apache 8.1.x fat apache N/A
thecodingmachine/php:8.1-v5-apache-node20 8.1.x fat apache 20.x
thecodingmachine/php:8.1-v5-apache-node22 8.1.x fat apache 22.x
thecodingmachine/php:8.1-v5-apache-node24 8.1.x fat apache 24.x
thecodingmachine/php:8.1-v5-apache-node26 8.1.x fat apache 26.x
thecodingmachine/php:8.1-v5-fpm 8.1.x fat fpm N/A
thecodingmachine/php:8.1-v5-fpm-node20 8.1.x fat fpm 20.x
thecodingmachine/php:8.1-v5-fpm-node22 8.1.x fat fpm 22.x
thecodingmachine/php:8.1-v5-fpm-node24 8.1.x fat fpm 24.x
thecodingmachine/php:8.1-v5-fpm-node26 8.1.x fat fpm 26.x
thecodingmachine/php:8.1-v5-cli 8.1.x fat cli N/A
thecodingmachine/php:8.1-v5-cli-node20 8.1.x fat cli 20.x
thecodingmachine/php:8.1-v5-cli-node22 8.1.x fat cli 22.x
thecodingmachine/php:8.1-v5-cli-node24 8.1.x fat cli 24.x
thecodingmachine/php:8.1-v5-cli-node26 8.1.x fat cli 26.x
thecodingmachine/php:8.1-v5-slim-apache 8.1.x slim apache N/A
thecodingmachine/php:8.1-v5-slim-fpm 8.1.x slim fpm N/A
thecodingmachine/php:8.1-v5-slim-cli 8.1.x slim cli N/A

Note: we also tag patch releases of PHP versions. So you can specify a specific patch release using thecodingmachine/php:8.4.1-v5-cli for instance. However, unless you have a very specific need (for instance if the latest patch release of PHP introduced regressions), believe you have no valid reason to ask explicitly for 8.4.1 for instance. When 8.4.2 is out, you certainly want to upgrade automatically to this patch release since patch releases contain only bugfixes. Also, we automatically rebuild X.Y images every week, but only the latest X.Y.Z patch release gets a rebuild. The other patch releases are frozen in time and will contain bugs and security issues. So use those with great care.

[Major].[minor] images are automatically updated when a new patch version of PHP is released, so the PHP 8.4 image will always contain the most up-to-date version of the PHP 8.4.x branch.

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.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.

Usage

The images are based on Ubuntu 24.04, with PHP from the ondrej/php repository.

Example with CLI:

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

Example with Apache:

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

Example with PHP-FPM:

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

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

Dockerfile

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

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

Documentation

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, user) and fpm APACHE_DOCUMENT_ROOT, APACHE_HTTP_PORT, APACHE_EXTENSION_*
Processes Startup commands, cron jobs and daemons run along with the main command STARTUP_COMMAND_*, CRON_*, DAEMON_*
Debugging and profiling Xdebug and Blackfire PHP_EXTENSION_XDEBUG, XDEBUG_CLIENT_HOST, BLACKFIRE_AGENT
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.

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

Stars

851 stars

Watchers

29 watching

Forks

Used by

Contributors

Languages