1

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.

3
  • Why not report this in their issue tracker? Commented 23 hours ago
  • 2
    For example, see github.com/docker-library/php/issues/1605 about this Commented 23 hours ago
  • @NicoHaase Fair point, I didn't think about it and presumed that it was the issue with my code. Feel free to add an answer to mention that opcache is now already installed and that this line have to be removed. Commented 23 hours ago

1 Answer 1

4

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)

Official PHP Docker image builds adopted to that already prior to PHP version 8.5.0 release that was yesterday. (ref)

However, 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.

2 Comments

Read the changelog :)” This is a good advice, that I very often forget…
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.