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 plainphp: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:fpmorphp: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:
- The images are built by the Docker Official Images team from the docker-library/php repository, and its versions.json lists every version and variant that exists.
- PHP 8.5 has four variants (
cli,apache,fpm,zts) and four bases (trixie,bookworm,alpine3.24,alpine3.23). There is no Apache or mod_php image on Alpine. - If you leave the base out you get Debian 13:
php:8.5-fpmandphp:8.5-fpm-trixiehad the same image ID in our test. - PHP released 8.5.13, 8.4.28, 8.3.37 and 8.2.36 as security releases and 8.6.0 as a new version on 19 November 2026 (php.net news archive). Floating tags such as
php:8.5-apache-trixiemoved to the new builds the same day or the day after. - Old patch tags stay online but never get a newer PHP:
php:8.5.12-apache-trixiestill pulls PHP 8.5.12, built on 5 November 2026, without the November fixes. - No image contains Composer, git or a
php.ini.
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.
| Part | Values for PHP 8.5 | If you leave it out |
|---|---|---|
| Version | 8.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 |
| Variant | cli, fpm, apache, zts | cli. php:8.5 and php:8.5-cli-trixie had the same image ID |
| Base | trixie (Debian 13), bookworm (Debian 12), alpine, alpine3.24, alpine3.23 | trixie. 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
fpmruns PHP-FPM, listens on port 9000 and speaks FastCGI, not HTTP. It needs a web server in front. The image description warns that FastCGI is "inherently trusting" and tells you not to publish that port (Docker Hub, php, Image Variants).apacheis Debian's Apache with PHP as mod_php. The docs say it "usesmpm_preforkby default". Our lab image reported Apache/2.4.71.mod_rewriteis not enabled until you runa2enmod rewrite.clihas no server. It startsphp -aand is, in the docs' words, "the only variant which contains the (not recommended)php-cgibinary". Every variant also contains thephpcommand.ztsis the CLI built with thread safety on, for runtimes that run PHP in threads, such as FrankenPHP or the parallel extension. Ordinary sites do not need it.
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 setup | Tag | Why |
|---|---|---|
| Nginx or Caddy plus PHP (WordPress, Laravel, most sites) | php:8.5.13-fpm-trixie | One process type per container, static files served by the web server, PHP workers tuned on their own |
One container, .htaccess rules, least setup | php:8.5.13-apache-trixie | Web server and PHP in one image; publish port 80 and it works |
| Cron jobs, queue workers, one-off scripts, CI | php:8.5.13-cli-trixie | No server process; the container ends when the script ends |
| Smallest image, slow links, many nodes | php:8.5.13-fpm-alpine | About a quarter of the download; test every extension you compile on musl first |
| FrankenPHP worker mode, parallel, threads | php:8.5.13-zts-trixie | Thread-safe build |
| Legacy app tied to Debian 12 libraries | php:8.4.28-fpm-bookworm | Same 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.
| Tag | PHP | OS inside | On disk | Download |
|---|---|---|---|---|
php:8.5-cli-trixie (= php:8.5) | 8.5.13 NTS | Debian 13.7 | 572 MB | 189.7 MB |
php:8.5-fpm-trixie | 8.5.13 NTS | Debian 13.7 | 517 MB | 177.9 MB |
php:8.5-apache-trixie | 8.5.13 NTS | Debian 13.7 | 524 MB | 182.0 MB |
php:8.5-zts-trixie | 8.5.13 ZTS | Debian 13.7 | 572 MB | 189.9 MB |
php:8.5-fpm-bookworm | 8.5.13 NTS | Debian 12.15 | 519 MB | 178.4 MB |
php:8.5-apache-bookworm | 8.5.13 NTS | Debian 12.15 | 526 MB | 182.5 MB |
php:8.5-cli-alpine | 8.5.13 NTS | Alpine 3.24.4 | 144 MB | 47.5 MB |
php:8.5-fpm-alpine | 8.5.13 NTS | Alpine 3.24.4 | 114 MB | 41.5 MB |
php:8.4-fpm-trixie | 8.4.28 NTS | Debian 13.7 | 499 MB | 175.7 MB |
php:fpm (= php:8.6-fpm-trixie) | 8.6.0 ZTS | Debian 13.7 | 515 MB | not 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 write | What you get | Good for |
|---|---|---|
php:fpm, php:8-fpm | Newest PHP of any branch; jumped from 8.5 to 8.6 | Trying things out. Not for production |
php:8.5-fpm-trixie | Newest 8.5.x on Debian 13; security fixes arrive on the next pull or build | Sites where you rebuild often and want fixes without editing files |
php:8.5.13-fpm-trixie | PHP 8.5.13 only | Production: PHP changes only when you change the number |
php:8.5.13-fpm-trixie@sha256:7fd2766b... | One exact image, byte for byte | Reproducible 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
- Included:
docker-php-ext-install,docker-php-ext-configure,docker-php-ext-enableanddocker-php-source, pluspeclon 8.5 and older. These compile extra extensions from the PHP source kept in the image. - Included: 37 modules on 8.5, among them curl, mbstring, openssl, PDO with SQLite, sodium, zlib and OPcache.
php -mlists them. - Not included:
pdo_mysql,mysqli,gd,intl,zip,redis. Add what your app needs. - Not included: a
php.ini. PHP reports "Loaded Configuration File => (none)" anddisplay_errorsis on. The folder/usr/local/etc/php/holdsphp.ini-developmentandphp.ini-production, and the docs say it is "strongly recommended to use the production config". - Not included: Composer and git, and on Debian also
unzip. Copy Composer from its own official image, as its Docker Hub page describes. - Blocked: Debian's own PHP packages.
apt-get install php-mysqlends withE: Package 'php-mysql' has no installation candidate, because the image pinsphp*packages to priority -1 on purpose.
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.
- Change the version in the
FROMline, for example fromphp:8.5.12-fpm-trixietophp:8.5.13-fpm-trixie. With a floating tag such asphp:8.5-fpm-trixiethere is nothing to edit. - Rebuild and make Docker fetch the base image again:
docker compose build --pull. If your compose file usesimage: php:...with no build, rundocker compose pull. - Recreate:
docker compose up -d. - 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.
- Docker Hub: php official image, description, image variants, configuration and "Running as an arbitrary user".
- Docker Hub: php tags, tag list, push dates and compressed sizes.
- docker-library/php on GitHub, the Dockerfiles, and versions.json with versions and variants.
- docker-library/docs, php, the source text of the image description.
- Pull request 1686 (8.6 images built as ZTS), pull request 1654 (PEAR dropped for 8.6) and issue 1719 (open request to reconsider).
- php.net news archive 2026, the releases of 19 November 2026.
- Docker Hub: composer official image.
- Debian releases, codenames trixie and bookworm.
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.