TheCodingMachinePHP images v5 docs GitHub

Images

All the images are published on Docker Hub as thecodingmachine/php:<tag>. A tag reads <PHP version>-v5-[slim-]<variant>[-node<NodeJS version>]:

  • slim: no extensions preloaded; without slim, the fat image has the most common extensions, Supercronic and the locale tools;
  • -node<N>: the fat image with NodeJS, npm and yarn.

See the variants to choose between cli, apache and fpm, and the supported versions.

Production: the slim image

In production, prefer the slim image: it contains only the extensions you list, so it is smaller and exposes less. The fat image, with the most common extensions and Supercronic, is handy in development.

Dockerfile with the slim image

The ARGs written before the FROM are read by the slim image during the build: PHP_EXTENSIONS lists the extensions to install, NODE_VERSION installs NodeJS (with npm and yarn), in any version published by NodeSource, 16 or later, even without a -node tag.

ARG PHP_EXTENSIONS="apcu intl pdo_mysql"
ARG NODE_VERSION=24
FROM thecodingmachine/php:8.6-v5-slim-apache

ENV TEMPLATE_PHP_INI=production

COPY --chown=docker:docker . /var/www/html
RUN composer install --no-dev --optimize-autoloader \
 && npm ci \
 && npm run build

Dockerfile with the fat image

The extensions are enabled with PHP_EXTENSION_<name>=1 (see Extensions), and NodeJS comes with the -node tags.

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

ENV TEMPLATE_PHP_INI=production \
    PHP_EXTENSION_INTL=1

COPY --chown=docker:docker . /var/www/html
RUN composer install --no-dev --optimize-autoloader \
 && npm ci \
 && npm run build

The fat image ignores the NODE_VERSION ARG. For a NodeJS version without a -node tag (here NodeJS 20), start from the fat image without NodeJS and install it from NodeSource; from NodeJS 25, add sudo npm install -g corepack before corepack enable:

FROM thecodingmachine/php:8.6-v5-apache

RUN sudo apt-get update \
 && sudo apt-get install -y --no-install-recommends gnupg \
 && sudo mkdir -p /etc/apt/keyrings \
 && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
 && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list \
 && sudo apt-get update \
 && sudo apt-get install -y --no-install-recommends nodejs \
 && sudo corepack enable && sudo corepack prepare yarn@stable --activate \
 && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*

compose.yml

In development, with the fat image and your project mounted:

services:
  app:
    image: thecodingmachine/php:8.6-v5-apache
    ports:
      - "80:80"
    volumes:
      - .:/var/www/html

With a Dockerfile, replace image: with build: .. These examples use the apache variant; for fpm, see the fpm variant.

All the tags

apache

PHP fat slim NodeJS
8.6 8.6-v5-apache 8.6-v5-slim-apache 8.6-v5-apache-node22 8.6-v5-apache-node24 8.6-v5-apache-node26
8.5 8.5-v5-apache 8.5-v5-slim-apache 8.5-v5-apache-node22 8.5-v5-apache-node24 8.5-v5-apache-node26
8.4 8.4-v5-apache 8.4-v5-slim-apache 8.4-v5-apache-node22 8.4-v5-apache-node24 8.4-v5-apache-node26
8.3 8.3-v5-apache 8.3-v5-slim-apache 8.3-v5-apache-node22 8.3-v5-apache-node24 8.3-v5-apache-node26
8.2 8.2-v5-apache 8.2-v5-slim-apache 8.2-v5-apache-node22 8.2-v5-apache-node24 8.2-v5-apache-node26
8.1 8.1-v5-apache 8.1-v5-slim-apache 8.1-v5-apache-node20 8.1-v5-apache-node22 8.1-v5-apache-node24 8.1-v5-apache-node26

fpm

PHP fat slim NodeJS
8.6 8.6-v5-fpm 8.6-v5-slim-fpm 8.6-v5-fpm-node22 8.6-v5-fpm-node24 8.6-v5-fpm-node26
8.5 8.5-v5-fpm 8.5-v5-slim-fpm 8.5-v5-fpm-node22 8.5-v5-fpm-node24 8.5-v5-fpm-node26
8.4 8.4-v5-fpm 8.4-v5-slim-fpm 8.4-v5-fpm-node22 8.4-v5-fpm-node24 8.4-v5-fpm-node26
8.3 8.3-v5-fpm 8.3-v5-slim-fpm 8.3-v5-fpm-node22 8.3-v5-fpm-node24 8.3-v5-fpm-node26
8.2 8.2-v5-fpm 8.2-v5-slim-fpm 8.2-v5-fpm-node22 8.2-v5-fpm-node24 8.2-v5-fpm-node26
8.1 8.1-v5-fpm 8.1-v5-slim-fpm 8.1-v5-fpm-node20 8.1-v5-fpm-node22 8.1-v5-fpm-node24 8.1-v5-fpm-node26

cli

PHP fat slim NodeJS
8.6 8.6-v5-cli 8.6-v5-slim-cli 8.6-v5-cli-node22 8.6-v5-cli-node24 8.6-v5-cli-node26
8.5 8.5-v5-cli 8.5-v5-slim-cli 8.5-v5-cli-node22 8.5-v5-cli-node24 8.5-v5-cli-node26
8.4 8.4-v5-cli 8.4-v5-slim-cli 8.4-v5-cli-node22 8.4-v5-cli-node24 8.4-v5-cli-node26
8.3 8.3-v5-cli 8.3-v5-slim-cli 8.3-v5-cli-node22 8.3-v5-cli-node24 8.3-v5-cli-node26
8.2 8.2-v5-cli 8.2-v5-slim-cli 8.2-v5-cli-node22 8.2-v5-cli-node24 8.2-v5-cli-node26
8.1 8.1-v5-cli 8.1-v5-slim-cli 8.1-v5-cli-node20 8.1-v5-cli-node22 8.1-v5-cli-node24 8.1-v5-cli-node26

Patch releases

Each patch release of PHP also has its tag, e.g. 8.6.1-v5-cli. Prefer the 8.6-v5-cli tag: it gets every patch release (which only contains bug fixes) and every rebuild of the images. The tag of a patch release is no longer rebuilt once the next one is out: it gets no more security fixes. Keep it for a specific need, e.g. a regression in the latest patch release, and see Security.