[英]Docker phpdockerio/php:8.1-fpm builds with PHP version 8.2: How can I revert to 8.1?
I'm running my project on a PHP-FPM docker container (details of config files below).我在 PHP-FPM docker 容器上运行我的项目(配置文件的详细信息如下)。 When I build my containers and attempt to run composer I'm getting errors reporting missing PHP extensions.当我构建我的容器并尝试运行 composer 时,我收到错误报告缺少 PHP 扩展。 However, I thought my build files where covering these extensions (see docker/php-fpm/Dockerfile
below).但是,我认为我的构建文件涵盖了这些扩展(请参阅下面docker/php-fpm/Dockerfile
)。
It turns out that the container is being built with php8.2 as the default version.事实证明,容器正在以 php8.2 作为默认版本构建。 I have been able to change the symlinks to set the default version back to php8.1 but this doesn't seem like the right solution.我已经能够更改符号链接以将默认版本设置回 php8.1 但这似乎不是正确的解决方案。 Can anyone suggest a better fix?谁能建议更好的解决方法?
How I know the container is running 8.2: Inside the container I ran php --version
and got:我怎么知道容器正在运行 8.2:在容器内,我运行了php --version
并得到:
root@fee8cc9ff790:/application# php --version
PHP 8.2.0 (cli) (built: Dec 8 2022 13:56:08) (NTS)
Then which php
gave me:然后which php
给了我:
root@fee8cc9ff790:/application# which php
/usr/bin/php
I followed the symlinks to find that linked PHP binaries in /etc/alternatives
are:我按照符号链接发现/etc/alternatives
中链接的 PHP 二进制文件是:
phar -> /usr/bin/phar8.2
phar.phar -> /usr/bin/phar.phar8.2
php -> /usr/bin/php8.2
phpdbg -> /usr/bin/phpdbg8.2
This is the bit that doesn't seem right to me.这一点对我来说似乎不对。 I was able to relink these to their 8.1 versions and things seem to be running fine now but what happens when I rebuild the container?我能够将它们重新链接到他们的 8.1 版本,现在一切似乎运行良好,但是当我重建容器时会发生什么?
Details of my files:我的文件的详细信息:
docker-compose.yml
###############################################################################
# Generated on docker.io #
###############################################################################
version: '3.9'
services:
mailhog:
image: 'mailhog/mailhog:latest'
redis:
image: 'redis:alpine'
mysql:
image: 'mysql:8.0.27'
working_dir: /application
platform: linux/amd64
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_DATABASE=
- MYSQL_USER=
- MYSQL_PASSWORD=
webserver:
image: 'nginx:alpine'
working_dir: /application
volumes:
- '.:/application'
- './docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf'
php-fpm:
build: docker/php-fpm
working_dir: /application/
volumes:
- '.:/application'
- './docker/php-fpm/php-ini-overrides.ini:/etc/php/8.1/fpm/conf.d/99-overrides.ini'
- './docker/php-fpm/php-ini-overrides.ini:/etc/php/8.1/cli/conf.d/99-overrides.ini'
docker-compose.override.yml
###############################################################################
# Generated on phpdocker.io #
###############################################################################
version: '3.9'
services:
mailhog:
ports:
- '8026:8025'
mysql:
ports:
- '33061:3306'
webserver:
ports:
- '801:80'
docker/php-fpm/Dockerfile
FROM phpdockerio/php:8.1-fpm
WORKDIR "/application"
RUN apt-get update; \
apt-get -y --no-install-recommends install \
git \
php-xdebug \
php8.1-mysql \
php8.1-sqlite \
mysql-client \
php8.1-redis; \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
This turned out to be caused by the extensions I was loading.原来这是由我正在加载的扩展引起的。 In docker/php-fpm/Dockerfile
I installed php-xdebug
which was causing the container to load up with PHP8.2在docker/php-fpm/Dockerfile
,我安装了php-xdebug
,它导致容器加载 PHP8.2
Specifying the 8.1 version php8.1-xdebug
solved the problem.指定 8.1 版本php8.1-xdebug
解决了这个问题。
Credit to luispabon for his response to the issue I raised on GitHub after thinking this must be a problem with the image.感谢 luispabon 对我在 GitHub 上提出的问题的回应,我认为这一定是图像的问题。 https://github.com/phpdocker-io/base-images/issues/62 https://github.com/phpdocker-io/base-images/issues/62
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.