在PHP Dockerfile中添加redis扩展导致安装失败

问题描述 投票:0回答:1

我想在 API 平台存储库中的 PHP dockerfile 中添加 Redis 扩展(link) 所以,我添加了以下命令:

RUN pecl install -o -f redis \
    &&  rm -rf /tmp/pear \
    &&  docker-php-ext-enable redis

(基于在 stackoverflow 答案中找到的解决方案)但是当我使用

docker-compose build
进行构建时,出现以下错误:

 > [app-php php_base  5/14] RUN pecl install -o -f redis &&  rm -rf /tmp/pear &&  docker-php-ext-enable redis:
#0 2.750 downloading redis-6.0.2.tgz ...
#0 2.750 Starting to download redis-6.0.2.tgz (365,966 bytes)
#0 2.750 ..........................................................................done: 365,966 bytes
#0 3.176 43 source files, building
#0 3.176 running: phpize
#0 3.180 Configuring for:
#0 3.180 PHP Api Version:         20220829
#0 3.180 Zend Module Api No:      20220829
#0 3.180 Zend Extension Api No:   420220829
#0 3.193 Cannot find autoconf. Please check your autoconf installation and the
#0 3.193 $PHP_AUTOCONF environment variable. Then, rerun this script.
#0 3.193 
#0 3.193 ERROR: `phpize' failed
------
failed to solve: process "/bin/sh -c pecl install -o -f redis &&  rm -rf /tmp/pear &&  docker-php-ext-enable redis" did not complete successfully: exit code: 1

我该如何修复它?或者还有其他方法来添加 redis 扩展吗? 谢谢各位的解答

php docker docker-compose redis
1个回答
0
投票

解决了:

RUN apk --no-cache add \
    autoconf \
    g++ \
    make \
    && pecl install -o -f redis \
    && rm -rf /tmp/pear \
    && docker-php-ext-enable redis
© www.soinside.com 2019 - 2024. All rights reserved.