我正在使用Alpine、php7.2-fpm和Composer构建Docker镜像。
安装Composer时出现了问题,它通过https协议下载安装程序。
为了能够安装php7.2及其软件包(用于安装Composer),我已经添加了存储库。
RUN wget -O /etc/apk/keys/phpearth.rsa.pub https://repos.php.earth/alpine/phpearth.rsa.pub && \
echo "https://repos.php.earth/alpine/v3.7" >> /etc/apk/repositories && \
apk update
当我尝试下载Composer时,出现以下错误:
/ # php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
PHP Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. copy() Command line code:1
PHP Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. copy() Command line code:1
PHP Warning: copy(https://getcomposer.org/installer): failed to open stream: No such file or directory in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. copy() Command line code:1
搜索有关此错误的信息,我发现所有相关的都与openssl php扩展有关。
尝试安装php7.2-openssl扩展时,我收到以下错误消息:
/ # apk add php7.2-openssl
ERROR: unable to select packages:
php7.2-igbinary (no such package):
required by: world[php7.2-igbinary]
php7.2-msgpack (no such package):
required by: world[php7.2-msgpack]
php7.2-readline (no such package):
required by: world[php7.2-readline]
so:libcrypto.so.42 (no such package):
required by: php7.2-openssl-7.2.16-r0[so:libcrypto.so.42]
so:libssl.so.44 (no such package):
required by: php7.2-openssl-7.2.16-r0[so:libssl.so.44]
如果我使用“-f”强制安装,看起来好像已经安装了,但实际上没有。命令apk list php* --installed
不会显示openssl扩展,并且https请求仍然返回相同的https错误。
另一种安装Composer的方法对我来说并不是最好的选择。最终我还是需要通过php使用https。
我正在使用截至目前为止的最新Alpine Docker基础镜像版本,即“3.14.2”。
我想知道这是否与添加的存储库版本(3.7)与镜像版本(3.14.2)有关。
我希望能够理解发生了什么事情。
docker pull php:7.2-fpm-alpine3.11
(可以正常工作)。我是随机选择那个日期和版本的,如果您需要特定版本,请查找。 - Don't Panic