If you run WordPress or another PHP application in Docker, here is how to move every container onto a PHP build with the October 2026 PHP2Shell fix, and how to prove it. PHP2Shell covers two critical remote code execution flaws, listed in the Common Vulnerabilities and Exposures (CVE) catalogue as CVE-2026-109618 and CVE-2026-109619. The PHP project fixed them in 8.2.35, 8.3.36, 8.4.27 and 8.5.12 on 21 October 2026 (php.net release archive). With containers, docker pull only downloads a new image, and every container you started earlier keeps running the old one. Rebuild on a fixed official php image, pin that image by its digest, recreate the containers, then check from inside each running container.
The official images checked below were first inspected on 30 October 2026 and checked again on 21 November 2026. Tags move, so re-check before you rely on a specific digest.
Update, 21 November 2026. The October versions are no longer the ones to aim for. On 19 November 2026 the PHP project released 8.2.36, 8.3.37, 8.4.28 and 8.5.13 as security releases (php.net release archive). They fix CVE-2026-115560. On 8.3 and later they also fix CVE-2026-129481, which the PHP project describes as an incomplete fix for CVE-2026-109619. Those four versions are now the minimum in each branch. The tags, the digest and the example outputs in the steps below use the November versions, confirmed on Docker Hub on 21 November 2026.
What you’ll accomplish
- A list of every running container with the PHP version it really runs, and whether it still uses an outdated image.
- A Dockerfile that starts from a fixed official tag, pinned by digest so the build cannot silently drift.
- Rebuilt images and recreated containers, using Docker Compose or plain
docker run. - Proof per container that its image ID matches the new image and that PHP reports a fixed version.
- The
session.upload_progress.enabled = 0setting baked into the image, which the PHP project recommends for a third flaw, CVE-2026-115560.
Prerequisites
- Shell access to the Docker host, as a user who can run
dockercommands. - Docker Engine with the Compose plugin (
docker compose) and the Buildx plugin, both part of Docker’s standard Engine install. The commands below were checked with Docker 29 and Compose 5. - The Dockerfile and
compose.yaml(ordocker-compose.yml) for each application, in version control. - A recent backup of your volumes and database. Recreating a container keeps named volumes, and a backup still gives you a way back if the new image misbehaves.
- If you cannot rebuild today, start with PHP2Shell mitigations until you can patch first.
How it works
Three different things share the name “the image”, and only one of them serves your visitors.
A tag such as php:8.3-fpm is a movable name in the registry. The Docker Official Images team rebuilds it whenever PHP or the underlying Debian or Alpine system changes. A local image is the copy on your host, identified by an image ID. A container is started from one specific image ID and keeps it for its whole life. Pulling or building a newer image moves the tag on your host to the new image ID, but it never touches a running container. Docker has no step that swaps the image under a live container. You must remove it and start a new one.
That is why the proof has to come from the running container itself. Two facts settle it. The container’s image ID must equal the ID of the image you built, and PHP inside it must report a fixed version.
One more trap sits in the base image. The official php image compiles PHP from the php.net source, so its version number moves to 8.3.37 and so on. A custom image that starts from debian or ubuntu and installs PHP with apt gets the distribution’s package instead. Those packages keep their old number and carry a backported fix, and they follow the distribution’s advisories, not the php.net numbers. Updating PHP on a Linux server after a security fix explains how to read those.
Step-by-step
-
List the PHP version inside every running container. This loop asks each running container for its PHP version. Containers without PHP, such as a database or an nginx proxy, print
no php:for c in $(docker ps --format '{{.Names}}'); do v=$(docker exec "$c" php -r 'echo PHP_VERSION;' 2>/dev/null || echo 'no php') printf '%-24s %s\n' "$c" "$v" doneExample output:
shop-wordpress-1 8.3.36 shop-db-1 no php intranet-php-1 8.2.30 api-worker-1 8.4.28As of 21 November 2026, any version below 8.2.36, 8.3.37, 8.4.28 or 8.5.13 in its own branch is missing a fix. A version from 8.1 or older is also unfixed, with no fixed official tag to move to (step 3 covers it). For one container,
docker exec <container> php -vprints the full banner, including the build date. -
Check where each image got its PHP. Official
phpimages, and thewordpressimage built on them, record the version in an environment variable:docker image inspect --format '{{range .Config.Env}}{{println .}}{{end}}' shop-wordpress:latest | grep '^PHP_VERSION='Example output:
PHP_VERSION=8.3.36If this prints nothing, PHP came from a distribution package. Check the package inside the container with
docker exec <container> dpkg -l 'php*'on Debian or Ubuntu, ordocker exec <container> apk info -von Alpine. Then compare the package version with that distribution’s security advisory. -
Pick a fixed official tag. You can read the PHP version of any tag before you pull it:
docker buildx imagetools inspect php:8.3.37-fpm-bookworm --format '{{json .Image}}' | grep -o 'PHP_VERSION=[0-9.]*' | sort -uExpected output:
PHP_VERSION=8.3.37Keep the same PHP branch, variant and operating system you use today, and change only the version. If you run
php:8.3-fpm-bookworm, move tophp:8.3.37-fpm-bookworm. Forphp:8.4-apache, move to a tag such asphp:8.4.28-apache-bookworm. Alpine users keep-alpine, as inphp:8.3.37-fpm-alpine. Name the Debian release (bookwormortrixie) on purpose. Tags without one follow the image’s default Debian release, trixie as of 21 November 2026, so an unsuffixed tag can change your operating system during a security update. For thewordpressimage, use a PHP-specific tag such aswordpress:php8.3-fpm, which on 21 November 2026 reportedPHP_VERSION=8.3.37for amd64 and arm64.Older branches are a dead end here. As of 21 November 2026, the official php image lists supported tags only for 8.2, 8.3, 8.4, 8.5 and 8.6. The
php:8.1-fpmtag still exists, but it was last rebuilt in December 2025 and reports 8.1.34, which has no PHP2Shell fix. The PHP project shipped no fixed 8.1, 8.0 or 7.4 release, so there is no fixed official tag for them. Move those applications to 8.3 or 8.4. Avoid 8.2 as a landing spot too, because its security support ends on 31 December 2026. -
Pin the base image by digest. A digest is the content fingerprint of one exact image, a long
sha256:value that never changes, unlike a tag. Get it for the tag you chose:docker buildx imagetools inspect php:8.3.37-fpm-bookwormExample output (abridged, fetched on 21 November 2026):
Name: docker.io/library/php:8.3.37-fpm-bookworm MediaType: application/vnd.oci.image.index.v1+json Digest: sha256:5b9440ebac23314bb42d33338918c1c2c852469e5b0a7f0a9493448d827bab35Use the
Digest:line at the top. It names the multi-architecture index, so the same pin works on Intel and ARM hosts. If the image is already pulled,docker image inspect --format '{{index .RepoDigests 0}}' php:8.3.37-fpm-bookwormprints the same value asphp@sha256:followed by the digest. Put the tag and the digest on theFROMline of your Dockerfile:FROM php:8.3.37-fpm-bookworm@sha256:5b9440ebac23314bb42d33338918c1c2c852469e5b0a7f0a9493448d827bab35When both are present, Docker uses the digest and keeps the tag only for people reading the file. Fetch your own digest rather than copying this one. The image behind a tag is rebuilt from time to time, and Docker Hub shows this one was last pushed on 19 November 2026.
-
Bake the CVE-2026-115560 setting into the image. CVE-2026-115560, published by the PHP project on 23 October 2026, is a separate flaw in the same session upload progress code. The October releases, 8.3.36 included, are exposed to it. PHP 8.5.13, 8.4.28, 8.3.37 and 8.2.36, released on 19 November 2026, fix it (php.net), so rebuild on one of those or newer. Switching the feature off is still worth keeping in the image. Session upload progress lets a page report how far a file upload has got, and few applications use it. Create a file named
zz-php2shell.ininext to the Dockerfile:session.upload_progress.enabled = 0Then copy it into PHP’s configuration directory. Official images store that path in
$PHP_INI_DIR, which is/usr/local/etc/php, and read every.inifile in itsconf.dfolder:COPY zz-php2shell.ini "$PHP_INI_DIR/conf.d/"The
zz-prefix makes the file load last, so no earlier file can switch the feature back on. If your Dockerfile does not do it already, consider addingRUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini". Official images ship without an activephp.ini, which leaves PHP on its built-in defaults. -
Rebuild without the cache. Build with a fresh base image and no reused layers:
docker compose build --pull --no-cacheWithout Compose, use
docker build --pull --no-cache -t shop-wordpress:latest .in the directory with the Dockerfile. The success signal is a line such asImage shop-wordpress:latest Builtfrom Compose, ornaming to docker.io/library/shop-wordpress:latest donenear the end of thedocker buildoutput.--pullfetches the base image even if an older copy exists locally.--no-cachematters most for images that install PHP withaptorapk. A cachedRUN apt-get installlayer would otherwise keep last month’s packages.For services that use a ready-made image with no
build:section, such as an unmodifiedwordpress:php8.3-fpm, update the tag incompose.yamland download it instead:docker compose pull -
Recreate the containers. Start new containers from the new images:
docker compose up -d --force-recreateExample output (abridged):
Container shop-db-1 Recreate Container shop-wordpress-1 Recreate Container shop-wordpress-1 Recreated Container shop-db-1 Recreated Container shop-db-1 Starting Container shop-wordpress-1 Starting Container shop-db-1 Started Container shop-wordpress-1 Starteddocker compose up -don its own already recreates services whose image changed.--force-recreateremoves any doubt, at the cost of also restarting unchanged services such as the database, so expect a short interruption. To limit it to one service, add the service name at the end, as indocker compose up -d --force-recreate wordpress. For a container started by hand withdocker run, stop and remove it, then run the samedocker runcommand again with the new tag. Named volumes survive this, but anything written inside the container’s own filesystem does not.
Validate it works
-
Compare each container’s image ID with its current image. This loop flags any container still running an older image than the one its tag now points to. It also prints the PHP version next to it:
for c in $(docker ps --format '{{.Names}}'); do ref=$(docker inspect --format '{{.Config.Image}}' "$c") running=$(docker inspect --format '{{.Image}}' "$c") current=$(docker image inspect --format '{{.Id}}' "$ref" 2>/dev/null) if [ "$running" = "$current" ]; then s='current'; else s='STALE'; fi v=$(docker exec "$c" php -r 'echo PHP_VERSION;' 2>/dev/null || echo 'no php') printf '%-24s %-30s %-8s %s\n' "$c" "$ref" "$v" "$s" doneExample output:
shop-wordpress-1 shop-wordpress:latest 8.3.37 current shop-db-1 mariadb:11.4 no php current intranet-php-1 intranet-php:latest 8.2.30 STALEEvery PHP container must read
currentwith a fixed version. ASTALErow means the image was rebuilt but the container was not recreated, so repeat step 7 for it. -
Check the version that PHP-FPM or Apache serves.
docker exec … phpruns a new command-line process. The web side is served by PHP-FPM (FastCGI Process Manager, the pool of PHP workers behind your web server) or by the Apache process that started with the container. In official images both come from the same build, so a recreated container is enough. To see it from the web anyway, write a throwaway file into the document root, request it through your site, then delete it. For thewordpressimage, the document root is/var/www/html:docker exec shop-wordpress-1 sh -c 'echo "<?php echo PHP_VERSION, \" \", PHP_SAPI;" > /var/www/html/kb-ver-7f3a.php' curl -s https://shop.example.com/kb-ver-7f3a.php; echo docker exec shop-wordpress-1 rm /var/www/html/kb-ver-7f3a.phpExpected output:
8.3.37 fpm-fcgifor PHP-FPM, or8.3.37 apache2handlerfor the Apache variant. WordPress users can skip the file. The PHP version also appears under Tools » Site Health » Info » Server. -
Confirm the mitigation is active. Ask the PHP-FPM binary, which reads the same
conf.dfolder as the web workers:docker exec shop-wordpress-1 php-fpm -i | grep session.upload_progress.enabledExpected output:
session.upload_progress.enabled => Off => OffOn the Apache variant, run
php -iinstead ofphp-fpm -i. PHP-FPM and Apache read.inifiles only when they start. If you ever copy the file into a running container, it has no effect until the container restarts, and a recreate is cleaner.
Troubleshooting
- The container still reports the old version after
docker compose up -d. Compose recreates a service only when it sees a change. Rundocker compose up -d --force-recreate <service>, then the validation loop again. If the version still does not move, theimage:line incompose.yamlprobably points to an old tag, so read it before you rebuild. - The rebuilt image still has the old PHP. A digest pin wins over the tag. If you changed the tag but kept an old
@sha256:value, Docker builds from the old image. Fetch the new digest withdocker buildx imagetools inspectand update theFROMline. PHP_VERSIONis fixed butdocker exec … php -vshows something else. Your Dockerfile installs a second PHP, usually fromapt, after the official base. Check withdocker exec <container> sh -c 'command -v php; ls /usr/bin/php*'. Keep one PHP per image.STALEappears for a container you did recreate. Another build ran afterwards and moved the tag again, for example a continuous integration (CI) job. Recreate once more after the last build, and pin your deploys to an image tag or digest that a later build cannot reuse.- A container fails to start after the recreate. Read
docker compose logs --tail 50 <service>. If your old tag had no release suffix, check whether the base operating system moved from bookworm to trixie. If it did, put-bookwormback in the tag and rebuild.
Keep it fixed
A digest pin stops silent drift, but it also stops automatic security rebuilds. Let a bot propose the next digest as a pull request. Dependabot’s docker package ecosystem and Renovate both update FROM lines that carry a tag and a digest. Renovate can also add digests to unpinned lines with its pinDigests option. Each time one lands, build, recreate and run the validation loop.
When this is the wrong approach
If a hosting platform runs your containers for you, it may rebuild and restart them on its own schedule. Ask the provider which image it uses and run the validation from its console instead. If your application still needs PHP 7.4, 8.0 or 8.1, no official image fixes it. Your options are a paid extended-support build from a third-party vendor, or upgrading the application. If you cannot rebuild today, the settings in the mitigation article reduce exposure in the meantime. They are not a fix.
If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.