3

I can build an image with this Dockerfile that is based on a lightweight Docker image that use Alpine:

FROM php:8.4.15-cli-alpine

RUN docker-php-ext-install opcache

But I can’t build an image after upgrading to PHP 8.5 — it should be noted that this 8.5 image was released only 16 hours ago:

FROM php:8.5.0-cli-alpine

RUN docker-php-ext-install opcache

It fails with this error:

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20250925/
cp: can't stat 'modules/*': No such file or directory
make: *** [Makefile:89: install-modules] Error 1

How to avoid this error? Do I have to wait for an update from docker-php-ext-install?

I tried to run docker-php-ext-configure opcache before docker-php-ext-install opcache and it worked, but didn’t fix the error.

2

1 Answer 1

6

As documented in the PHP 8.5 changelog, since PHP 8.5 the Opcache extension now always ships with PHP (non-optional). So you don't need to install it any longer.

  • Opcache:
    • Make OPcache non-optional (Arnaud, timwolla)

Using zend_extension=opcache.so or zend_extension=php_opcache.dll INI directives will emit a warning.

If you're looking for the backward incompatible changes of the now non-shared opcache extension, see section Opcache in appendix Migrating from PHP 8.4.x to PHP 8.5.x of the PHP Manual for the whole picture.

Official PHP Docker image builds adopted to that already prior to PHP version 8.5.0 release that was yesterday (at the time of asking). (ref)

One reason is, that the Docker library PHP image nowadays has better support for RC candidates. If you make use of them earlier (e.g. to stage your PHP version migrations), this would also be helpful in testing the new releases. Maybe next time? It's a win-win!


Note: Under circumstances you may need to enable it (because Opcache as a feature still can be disabled). This is not the case with all official image builds (PHP 8.5...).

RUN /bin/sh -c 'if php -m | grep -qi "$1$"; then  \
       printf "%s already installed\n" "$1";      \
    else docker-php-ext-install -- "$1"; fi' --   \
       opcache

Listing 1: Install PHP Opcache (if not yet installed)

RUN docker-php-ext-enable opcache || true

Listing 2: Enable PHP Opcache (with allow failure) (ref)

Sign up to request clarification or add additional context in comments.

1 Comment

@A.L: Well it's longer for the .0 release, but most likely worth that your container build has "reminded" you of the Opcache changes and there are a couple of features specifically for containers with it. Benjamin (for Tideways) was so nice to write-up What’s new in PHP 8.5 in terms of performance, debugging and operations that discusses some of them under Operations.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.