← Back to Blog

PHP Docker Image Tags Explained: fpm, apache, cli, trixie, bookworm and alpine

Published · by Leo Gashi, RS Computers

PHP Docker Guides

An official PHP Docker image tag reads as php:<version>-<variant>-<base>, so php:8.5-apache-trixie means the newest PHP 8.5 patch release, with Apache and mod_php, on Debian 13 "trixie". For a site behind Nginx pick php:8.5-fpm-trixie, for one all-in-one container pick php:8.5-apache-trixie, for cron jobs and workers pick php:8.5-cli-trixie, and for the smallest download pick php:8.5-fpm-alpine.

Quick answer: which PHP Docker tag?

  • Nginx or Caddy in front: php:8.5-fpm-trixie (PHP-FPM on port 9000, no web server inside).
  • One container that serves the site: php:8.5-apache-trixie (Apache 2.4 with mod_php on port 80).
  • Scripts, cron, queue workers, Composer: php:8.5-cli-trixie, which is the same image as plain php:8.5.
  • Smallest image: php:8.5-fpm-alpine, 114 MB on disk against 517 MB for the Debian one in our test.
  • Production: write the full patch version, for example php:8.5.13-fpm-trixie, and change it yourself when PHP ships a fix.
  • Do not use php:latest, php:fpm or php:apache: since 19 November 2026 they are PHP 8.6.0.

We pulled over 20 of these tags on a Debian 13 test machine on 23 November 2026 and wrote down what is inside each one. The numbers are below, with a tested Dockerfile and compose file for Nginx with PHP-FPM and for Apache. If you want a server to run them on, our KVM VPS and VDS plans in Amsterdam, Dublin and Prishtina come with full root and NVMe storage, so Docker installs with one command.

Key facts, checked 23 November 2026:

How PHP Docker image tags are built: version, variant, base

Every tag is up to three parts joined by hyphens. Any part you leave out is filled in with a default, which is why so many tags point to one image.

PartValues for PHP 8.5If you leave it out
Version8.5.13 (one exact release), 8.5 (newest 8.5.x), 8 (newest 8.x), 8.5-rc (release candidates)You get the newest stable PHP of any branch. php:fpm was PHP 8.6.0 in our test
Variantcli, fpm, apache, ztscli. php:8.5 and php:8.5-cli-trixie had the same image ID
Basetrixie (Debian 13), bookworm (Debian 12), alpine, alpine3.24, alpine3.23trixie. Plain alpine means the newest Alpine, 3.24 today

So php:8.5.12-fpm-trixie is PHP 8.5.12, PHP-FPM, Debian 13, and php:8.4.27-fpm-bookworm is PHP 8.4.27, PHP-FPM, Debian 12. Both were built on 5 November 2026 and are one security release behind.

The four variants

trixie vs bookworm vs alpine

Trixie and bookworm are Debian 13 and Debian 12 (Debian releases). The PHP inside is the same version, compiled from the same source; what differs is the system libraries around it and the packages you can add with apt-get. Choose trixie for new work. Keep bookworm only if your Dockerfile installs a Debian 12 package that you have not tested on 13.

Alpine is a different kind of Linux. The image description says it uses "musl libc instead of glibc", and that is the whole trade: a much smaller image, and now and then a compiled extension or binary that expects glibc and will not run. Alpine also uses apk instead of apt-get, has no bash, and its www-data user is uid 82, not 33 as on Debian. That last one matters when two containers share files.

Which PHP Docker tag should you use?

Your setupTagWhy
Nginx or Caddy plus PHP (WordPress, Laravel, most sites)php:8.5.13-fpm-trixieOne process type per container, static files served by the web server, PHP workers tuned on their own
One container, .htaccess rules, least setupphp:8.5.13-apache-trixieWeb server and PHP in one image; publish port 80 and it works
Cron jobs, queue workers, one-off scripts, CIphp:8.5.13-cli-trixieNo server process; the container ends when the script ends
Smallest image, slow links, many nodesphp:8.5.13-fpm-alpineAbout a quarter of the download; test every extension you compile on musl first
FrankenPHP worker mode, parallel, threadsphp:8.5.13-zts-trixieThread-safe build
Legacy app tied to Debian 12 librariesphp:8.4.28-fpm-bookwormSame PHP, older base; plan the move to trixie

FPM or Apache is mostly a question of who serves the static files. With FPM you run two containers and Nginx hands only .php requests to PHP. With Apache every request goes through a process that has PHP loaded. Idle, our FPM container used 21 MiB and Nginx 8 MiB; the Apache container used 26 MiB. We did not benchmark them under load.

Measured: size, PHP version and OS of ten current tags

"On disk" is the SIZE column of docker images after docker pull on amd64. "Download" is the compressed amd64 size reported by Docker Hub. PHP and OS come from php -v and /etc/os-release inside each container.

TagPHPOS insideOn diskDownload
php:8.5-cli-trixie (= php:8.5)8.5.13 NTSDebian 13.7572 MB189.7 MB
php:8.5-fpm-trixie8.5.13 NTSDebian 13.7517 MB177.9 MB
php:8.5-apache-trixie8.5.13 NTSDebian 13.7524 MB182.0 MB
php:8.5-zts-trixie8.5.13 ZTSDebian 13.7572 MB189.9 MB
php:8.5-fpm-bookworm8.5.13 NTSDebian 12.15519 MB178.4 MB
php:8.5-apache-bookworm8.5.13 NTSDebian 12.15526 MB182.5 MB
php:8.5-cli-alpine8.5.13 NTSAlpine 3.24.4144 MB47.5 MB
php:8.5-fpm-alpine8.5.13 NTSAlpine 3.24.4114 MB41.5 MB
php:8.4-fpm-trixie8.4.28 NTSDebian 13.7499 MB175.7 MB
php:fpm (= php:8.6-fpm-trixie)8.6.0 ZTSDebian 13.7515 MBnot recorded

Trixie and bookworm are the same size within 2 MB, so size is no reason to choose between them. Alpine keeps its lead after you add extensions: we compiled gd and pdo_mysql into both FPM images, which took 20 seconds on Debian and 18 seconds on Alpine on 8 cores, and ended with 525 MB against 119 MB.

Why php:8.5-apache-trixie changed this month, and how to pin

A tag is a label that the maintainers move. On 19 November 2026 PHP shipped four security releases, and within a day php:8.5-apache-trixie pointed at a new image with PHP 8.5.13 in place of 8.5.12. Docker Hub shows that tag as last pushed on 20 November 2026; the PHP inside reports "built: Nov 19 2026". Anyone who ran docker pull or a fresh CI build after that got a different PHP without changing a line. The fixes themselves are covered in our guide to the November 2026 PHP security update.

The same day, the tags with no version made a bigger jump. In our test php:latest, php:fpm, php:apache and php:8-fpm all returned PHP 8.6.0. The 8.6 images also differ in two ways we could see: every one we pulled was a thread-safe (ZTS) build, including FPM and Apache, and pecl and pear are gone from /usr/local/bin. Both are deliberate changes in the repository (pull request 1686, pull request 1654), and the ZTS one is under discussion again in an open issue, so check before you build on it.

You writeWhat you getGood for
php:fpm, php:8-fpmNewest PHP of any branch; jumped from 8.5 to 8.6Trying things out. Not for production
php:8.5-fpm-trixieNewest 8.5.x on Debian 13; security fixes arrive on the next pull or buildSites where you rebuild often and want fixes without editing files
php:8.5.13-fpm-trixiePHP 8.5.13 onlyProduction: PHP changes only when you change the number
php:8.5.13-fpm-trixie@sha256:7fd2766b...One exact image, byte for byteReproducible builds and audits; needs a tool or a habit to update it

Pinning the patch version is only safe if somebody raises it. A pinned 8.5.12 or 8.4.27 will run for years without a single PHP security fix. To see the digest of an image you have pulled:

docker image inspect php:8.5-fpm-trixie --format '{{index .RepoDigests 0}}'
php@sha256:7fd2766bd3bb6efcfb49591e4bf014e123c18f01149093bd508525c6bdf0cf9f

That was the amd64 result on 23 November 2026, and php:8.5.13-fpm-trixie gave the same one. Yours will differ once the image is rebuilt.

What is and is not inside the official PHP image

A tested Dockerfile and compose file for Nginx with PHP-FPM

Make a folder with four files. src/index.php is your code; ours printed the PHP version, the SAPI and the user.

Dockerfile:

FROM php:8.5.13-fpm-trixie
RUN docker-php-ext-install -j"$(nproc)" pdo_mysql \
 && mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
USER www-data

nginx.conf:

server {
    listen 80;
    root /var/www/html;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass php:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

compose.yaml:

services:
  php:
    build: .
    restart: unless-stopped
    volumes:
      - ./src:/var/www/html:ro
  web:
    image: nginx:1.30
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./src:/var/www/html:ro
    depends_on:
      - php

Start it and ask for the page:

docker compose up -d --build
curl -s http://127.0.0.1:8080/
PHP 8.5.13 via fpm-fcgi, user www-data, pdo_mysql yes, opcache on, display_errors=''

The name php in fastcgi_pass php:9000 is the compose service name; if Nginx stops with an error about that name, see host not found in upstream in Docker. Both containers mount the code at the same path, because Nginx sends PHP-FPM a file path, not the file. Only the web service has a ports line; port 9000 stays inside. If the page returns 502, our 502 Bad Gateway guide walks through the log lines. The mount is read-only here; an app that writes uploads or cache needs a writable volume for those folders.

The same site on the Apache image

Dockerfile:

FROM php:8.5.13-apache-trixie
RUN docker-php-ext-install -j"$(nproc)" pdo_mysql \
 && a2enmod rewrite \
 && mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY src/ /var/www/html/

compose.yaml:

services:
  web:
    build: .
    restart: unless-stopped
    ports:
      - "8081:80"
docker compose up -d --build
curl -s http://127.0.0.1:8081/
PHP 8.5.13 via apache2handler, user www-data, pdo_mysql yes, opcache on, display_errors=''

The response carried X-Powered-By: PHP/8.5.13, because expose_php is on by default; turn it off in a file under $PHP_INI_DIR/conf.d/ if you would rather not announce the version. New to containers on a server? Our guide to running Docker containers on a VPS covers the install and the basics.

How to update a PHP container safely

Restarting a container never updates PHP. The container keeps the image it was created from, so the order is always: get the new image, recreate the container, check.

  1. Change the version in the FROM line, for example from php:8.5.12-fpm-trixie to php:8.5.13-fpm-trixie. With a floating tag such as php:8.5-fpm-trixie there is nothing to edit.
  2. Rebuild and make Docker fetch the base image again: docker compose build --pull. If your compose file uses image: php:... with no build, run docker compose pull.
  3. Recreate: docker compose up -d.
  4. Verify the running container, not the image: docker compose exec php php -v, then load a page.

We did exactly this from 8.5.12 to 8.5.13:

 Container app-fpm-php-1  Recreate
 Container app-fpm-php-1  Recreated
 ...
 Container app-fpm-web-1  Started
PHP 8.5.13 (cli) (built: Nov 19 2026 14:29:37) (NTS)

Keep the old image until the site is checked; going back is the same four steps with the old number.

Security: who runs PHP inside the container

With no USER line, the main process starts as root and the processes that run your code do not. In the FPM image, docker top showed php-fpm: master process as root and each php-fpm: pool www worker as www-data. Apache was the same: one root parent, www-data children.

You can drop root entirely. With USER www-data in the Dockerfile, or --user www-data on docker run, the FPM master also ran as www-data and logged two harmless notices:

NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root

The Apache image also started as www-data on port 80 on our Docker 26.1.5, where the container was allowed to bind low ports without root. Three more habits cost nothing: never publish port 9000, mount code read-only where the app allows it, and use php.ini-production so errors go to the log and not to visitors.

How we tested

All commands ran on 23 November 2026 in a fresh Debian 13 system container with 8 CPU cores and 2 GiB of memory, on Linux kernel 6.12, amd64. Docker was Debian's own package, version 26.1.5, with Docker Compose 2.26.1 and the overlay2 storage driver. We pulled over 20 tags of the official php image and ran php -v, php -m, id and cat /etc/os-release in each; built and requested both stacks above with Nginx 1.30.7 and Composer 2.11.2; changed the pinned version and recreated the containers; and built gd plus pdo_mysql on Debian and Alpine with docker build --no-cache. Download sizes came from the Docker Hub tags API the same day.

What we did not test: arm64 images, performance under load, Alpine with extensions beyond gd and pdo_mysql, PHP 8.6 beyond its version, thread safety and file list, and Docker's containerd image store, which reports sizes differently. Image sizes change with every rebuild, so treat ours as the state on that day.

Frequently asked questions

What does php:8.5-apache-trixie mean?

It is the official PHP image with the newest PHP 8.5 patch release, Apache 2.4 with mod_php, on Debian 13 "trixie". On 23 November 2026 it contained PHP 8.5.13 and Apache 2.4.71 on Debian 13.7. It is the same image as php:8.5-apache, because trixie is the default base.

What is the difference between the PHP fpm and apache Docker images?

The fpm image runs only PHP-FPM on port 9000 and needs a web server such as Nginx in a second container. The apache image contains Apache and PHP together and answers HTTP on port 80 by itself. Use fpm behind Nginx or Caddy, and apache when you want one container or rely on .htaccess files.

Should I use trixie, bookworm or alpine for PHP in Docker?

Use trixie (Debian 13) unless you have a reason not to; it is the default base of the official image. Bookworm (Debian 12) is for projects that still depend on Debian 12 packages. Alpine gives a much smaller image, 114 MB against 517 MB for PHP 8.5 FPM in our test, but uses musl libc, so test your extensions on it first.

Is php:8.5.12-apache-trixie still safe to use?

Not for a public site. It still downloads, but it is frozen at PHP 8.5.12 from 5 November 2026 and does not have the security fixes released in PHP 8.5.13 on 19 November 2026. Change the tag to php:8.5.13-apache-trixie or a newer patch release, rebuild and recreate the container.

Does the official PHP Docker image include Composer?

No. None of the variants we checked had Composer or git. Add COPY --from=composer:2 /usr/bin/composer /usr/bin/composer to your Dockerfile; in our build that gave Composer 2.11.2.

How do I install a PHP extension such as pdo_mysql in the Docker image?

Use the helper script that ships in the image: RUN docker-php-ext-install pdo_mysql. Extensions with library dependencies, such as gd, need those development packages installed with apt-get or apk first. Do not use apt-get install php-mysql; the image blocks Debian's PHP packages.

Why did my PHP version change when I did not change my Dockerfile?

Because the tag in your FROM line is a floating one. php:8.5-fpm follows every new 8.5 patch release, and php:fpm or php:latest follow every new PHP version, which is how they became PHP 8.6.0 after 19 November 2026. Write the full version, such as php:8.5.13-fpm-trixie, to decide yourself when it changes.

Sources

All checked on 23 November 2026.

Need a hand?

Would you rather skip containers? Our guide shows how to install PHP on Debian 13 from packages. If Docker is the plan, a VPS or VDS with NVMe in Amsterdam, Dublin or Prishtina gives you full root, a dedicated IPv4 and IPv6 address and free weekly backups to fall back on before an upgrade. Busy PHP sites whose FPM workers all want CPU at once sit better on a VDS with dedicated vCPUs. And if you want the stack built for you, we do custom offers, custom setups and systems built for you, quoted per job: write to us on Telegram or by email at info@rscomputers-ks.com.

← All articles

Chat on Telegram