问题描述
我有一个Dockerfile
,带有这样的构建命令:
I have a Dockerfile
with a build command like this:
#install some base extensions
RUN apt-get install -y \
zlib1g-dev \
zip \
&& docker-php-ext-install zip
我从构建输出中收到此警告:
I get this warning from build output:
在没有这些警告的情况下安装zip扩展的正确方法是什么?
What is the correct way to install the zip extension without these warnings?
我完整的Dockerfile如下:
My complete Dockerfile looks like:
FROM php:7.2-apache
RUN apt-get clean
RUN apt-get update
#install some basic tools
RUN apt-get install -y \
git \
tree \
vim \
wget \
subversion
#install some base extensions
RUN apt-get install -y \
zlib1g-dev \
zip \
&& docker-php-ext-install zip
#setup composer
RUN curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/ \
&& ln -s /usr/local/bin/composer.phar /usr/local/bin/composer
WORKDIR /var/www/
推荐答案
它看起来像 PHP不再捆绑了 libzip .您需要安装它.您安装zlib1g-dev
,但安装libzip-dev
.这会将zlib1g-dev
安装为依赖项,并允许configure
脚本检测到已安装libzip
.
It looks like PHP no longer bundles libzip. You need to install it. You install zlib1g-dev
, but instead install libzip-dev
. This installs zlib1g-dev
as a dependency and allows the configure
script to detect that libzip
is installed.
对于PHP< 7.3,然后您需要
For PHP < 7.3, you then need to
docker-php-ext-configure zip --with-libzip
使用
docker-php-ext-install zip
如最后警告所示.
简而言之:将Dockerfile的相关部分更改为
In short: change the relevant part of your Dockerfile to
对于PHP< 7.3
#install some base extensions
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
对于PHP> = 7.3
#install some base extensions
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-install zip
我已验证它可以按预期构建.
I have verified that this builds as expected.
如果您不使用Docker PHP基本映像,则事情可能会容易得多.例如,对于Alpine,以下Dockerfile将为您提供安装了zip扩展名的PHP 7.
In case you are not using the Docker PHP base image, things may be much easier. For example, for Alpine the following Dockerfile will get you PHP 7 with the zip extension installed.
FROM alpine:latest
RUN apk update && apk upgrade
RUN apk add php7 php7-zip composer
这篇关于使用PHP zip扩展名的Docker映像构建显示“已弃用捆绑的libzip"警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!