I’m trying to update a docker wordpress container to include php8.4.27 from ppa:ondrej/php.
I installed php8.4.27 on my host Ubuntu server using add-apt-repository and apt install php8.4
I tried to do the same in this Dockerfile, but it could find add-apt-repository or php8.4
The Dockerfile below uses copies of ondrej-ubuntu-php-noble.sources and ondrej-ubuntu-php-xenial.sources from the host /etc/apt/sources.list.d folder, but I still get the following message:
** Package php8.4 is not available, but is referred to by another package.
I presume the OS in the FROM image is not noble or xenial, but cannot work out what repository to use.
FROM wordpress:7.1.3-php8.4-apache
COPY ondrej-ubuntu-php-noble.sources /etc/apt/sources.list.d/ondrej-ubuntu-php-noble.sources
COPY ondrej-ubuntu-php-xenial.sources /etc/apt/sources.list.d/ondrej-ubuntu-php-xenial.sources
RUN apt update
RUN apt -y install php8.4
The trick is to override the entrypoint script with bash, and then use -c "shell command" to execute whatever you want. This image uses Debian 13, so the Ubuntu PPA repository probably shouldn’t be used here.
You can find out which php version comes with the image:
me@host \~ % docker run --rm --entrypoint bash wordpress:7.1.3-php8.4-apache -c "php --version"
PHP 8.4.27 (cli) (built: Oct 21 2026 15:58:11) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.27, Copyright (c) Zend Technologies
with Zend OPcache v8.4.27, Copyright (c), by Zend Technologies
The tag already indicates the image comes with php 8.4, and 8.4.27 is just a patch version of it
What is the reason that you want to install the version from a third party repository?
I hadn’t realised that wordpress:7.1.3-php8.4-apache had been upgraded to use the latest php8.4 patch.
Rebuilding my wp-php-apache container achieved what I was searching for, and upgraded my container’s PHP to 8.4.27 (required to prevent the latest cyber-security scare).