gpt4 book ai didi

php - Docker 在具有 curl 支持的 alpine 图像上构建 php 失败。我该如何解决?

转载 作者:行者123 更新时间:2023-12-04 17:17:06 27 4
gpt4 key购买 nike

我尝试在 php:7-fpm-alpine 上为 php 安装 curl 支持图片。因此我使用以下 Dockerfile :

FROM php:7-fpm-alpine

RUN apk add --update libzip-dev libcurl &&\
docker-php-ext-install curl && \
apk del gcc g++ &&\
rm -rf /var/cache/apk/*

但以与此类似的方式 question我很难安装所需的 libcurl即使使用 apk安装所需的库,如构建输出所示:
Building base
Step 1/2 : FROM php:7-fpm-alpine
---> 3a7affb05baa
Step 2/2 : RUN apk add --update libzip-dev libcurl && docker-php-ext-install curl && apk del gcc g++ && rm -rf /var/cache/apk/*
---> Running in 27a225ce5f91
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/4) Installing pkgconf (1.6.0-r0)
(2/4) Installing zlib-dev (1.2.11-r1)
(3/4) Installing libzip (1.5.1-r2)
(4/4) Installing libzip-dev (1.5.1-r2)
Executing busybox-1.29.3-r10.trigger
OK: 18 MiB in 34 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/24) Installing m4 (1.4.18-r1)
(2/24) Installing libbz2 (1.0.6-r6)
(3/24) Installing perl (5.26.3-r0)
(4/24) Installing autoconf (2.69-r2)
(5/24) Installing dpkg-dev (1.19.2-r0)
(6/24) Installing dpkg (1.19.2-r0)
(7/24) Installing libmagic (5.36-r0)
(8/24) Installing file (5.36-r0)
(9/24) Installing libgcc (8.3.0-r0)
(10/24) Installing libstdc++ (8.3.0-r0)
(11/24) Installing binutils (2.31.1-r2)
(12/24) Installing gmp (6.1.2-r1)
(13/24) Installing isl (0.18-r0)
(14/24) Installing libgomp (8.3.0-r0)
(15/24) Installing libatomic (8.3.0-r0)
(16/24) Installing mpfr3 (3.1.5-r1)
(17/24) Installing mpc1 (1.0.3-r1)
(18/24) Installing gcc (8.3.0-r0)
(19/24) Installing musl-dev (1.1.20-r4)
(20/24) Installing libc-dev (0.7.1-r0)
(21/24) Installing g++ (8.3.0-r0)
(22/24) Installing make (4.2.1-r2)
(23/24) Installing re2c (1.1.1-r0)
(24/24) Installing .phpize-deps (0)
Executing busybox-1.29.3-r10.trigger
OK: 218 MiB in 58 packages
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20180731
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 1.1.1 (ok)
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for cURL support... yes, shared
checking for pkg-config... /usr/bin/pkg-config
checking for libcurl.pc... using default path
checking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support
Removing intermediate container 27a225ce5f91
ERROR: Service 'base' failed to build: The command '/bin/sh -c apk add --update libzip-dev libcurl && docker-php-ext-install curl && apk del gcc g++ && rm -rf /var/cache/apk/*' returned a non-zero code: 1

我也尝试将以下内容更改为我的 Dockerfile (使用 curl 而不是 libcurl )
FROM php:7-fpm-alpine

RUN apk add --update libzip-dev curl &&\
docker-php-ext-install curl && \
apk del gcc g++ &&\
rm -rf /var/cache/apk/*

也失败了:
Building base
Step 1/2 : FROM php:7-fpm-alpine
---> 3a7affb05baa
Step 2/2 : RUN apk add --update libzip-dev curl && docker-php-ext-install curl && apk del gcc g++ && rm -rf /var/cache/apk/*
---> Running in 017b831ba617
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/4) Installing pkgconf (1.6.0-r0)
(2/4) Installing zlib-dev (1.2.11-r1)
(3/4) Installing libzip (1.5.1-r2)
(4/4) Installing libzip-dev (1.5.1-r2)
Executing busybox-1.29.3-r10.trigger
OK: 18 MiB in 34 packages
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/24) Installing m4 (1.4.18-r1)
(2/24) Installing libbz2 (1.0.6-r6)
(3/24) Installing perl (5.26.3-r0)
(4/24) Installing autoconf (2.69-r2)
(5/24) Installing dpkg-dev (1.19.2-r0)
(6/24) Installing dpkg (1.19.2-r0)
(7/24) Installing libmagic (5.36-r0)
(8/24) Installing file (5.36-r0)
(9/24) Installing libgcc (8.3.0-r0)
(10/24) Installing libstdc++ (8.3.0-r0)
(11/24) Installing binutils (2.31.1-r2)
(12/24) Installing gmp (6.1.2-r1)
(13/24) Installing isl (0.18-r0)
(14/24) Installing libgomp (8.3.0-r0)
(15/24) Installing libatomic (8.3.0-r0)
(16/24) Installing mpfr3 (3.1.5-r1)
(17/24) Installing mpc1 (1.0.3-r1)
(18/24) Installing gcc (8.3.0-r0)
(19/24) Installing musl-dev (1.1.20-r4)
(20/24) Installing libc-dev (0.7.1-r0)
(21/24) Installing g++ (8.3.0-r0)
(22/24) Installing make (4.2.1-r2)
(23/24) Installing re2c (1.1.1-r0)
(24/24) Installing .phpize-deps (0)
Executing busybox-1.29.3-r10.trigger
OK: 218 MiB in 58 packages
Configuring for:
PHP Api Version: 20180731
Zend Module Api No: 20180731
Zend Extension Api No: 320180731
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-musl
checking host system type... x86_64-pc-linux-musl
checking target system type... x86_64-pc-linux-musl
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20180731
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 1.1.1 (ok)
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for cURL support... yes, shared
checking for pkg-config... /usr/bin/pkg-config
checking for libcurl.pc... using default path
checking for cURL 7.15.5 or greater... configure: error: cURL version 7.15.5 or later is required to compile php with cURL support
Removing intermediate container 017b831ba617
ERROR: Service 'base' failed to build: The command '/bin/sh -c apk add --update libzip-dev curl && docker-php-ext-install curl && apk del gcc g++ && rm -rf /var/cache/apk/*' returned a non-zero code: 1

你知道如何解决这个问题吗?

最佳答案

您可能需要 curl-dev包裹。

FROM php:7-fpm-alpine

RUN apk add --update libzip-dev curl-dev &&\
docker-php-ext-install curl && \
apk del gcc g++ &&\
rm -rf /var/cache/apk/*

关于php - Docker 在具有 curl 支持的 alpine 图像上构建 php 失败。我该如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56581163/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com