since the latest php fpm docker image update yesterday (https://hub.docker.com/_/php?tab=tags&page=1&name=fpm-alpine) my pipeline is broken because apparently PHP version 8 is installed instead of 7.4 as in my Dockerfile specified.
I am using this in my docker file:
FROM php:7.4-fpm-alpine AS ...
But according to my composer installs the container has PHP 8.0.13 running:
Root composer.json requires php 7.4.26 but your php version (8.0.13) does not satisfy that requirement.
Anyone an idea what is going on here?
4
Answers
I had the same problem today…
Try:
Fixed it for me.
Code and Idea are from
https://stackoverflow.com/users/564000/armin
The alpine PHP images you reference do not include composer, so how are you installing it? If you are using apk to installer composer, it looks like the latest alpine composer package is pulling php8 in as a dependency, and this is causing your issue. What solved this issue for me was to install composer using the install script from getcomposer.org instead of using apk.
Assuming this is what you are doing, remove this from your Dockerfile:
and add:
If composer is indeed included in your base image (unlikely), you could try uninstalling first:
and then add the above code to install it from the setup script instead.
Edit: adding the ignore-platform-reqs flag will probably get you past the error, but you are introducing a possible point of failure in the future if you have a composer package with a platform requirement. In that case, you won’t know about the error until runtime. I would not recommend that approach. The method I posted above will install composer using the version of PHP already on the system and will not require risky workarounds.
As Jeremy Brooks already mentioned, Alpine released version 3.15 where composer requires PHP 8 (https://pkgs.alpinelinux.org/package/v3.15/community/x86_64/composer). Instead of installing composer from getcomposer.org another solution is to use Alpine 3.14:
I’m currently working on my docker-compose file to install laravel 8 with php 8.
I tested "php:7.4-fpm-alpine", and when I access the container I’m getting this version of php :
You can test it yourself :
I’m getting PHP 8.0.13 when installing "php:8.0-fpm-alpine"
Also I’m creating my laravel project using the composer image, I don’t have php/composer installed locally. It’s something you might have a look, because it could be quickly confusing 😉