使用PHP zip扩展名的Docker映像构建显示“已弃用捆绑的libzip"警告 [英] Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning

查看:737
本文介绍了使用PHP zip扩展名的Docker映像构建显示“已弃用捆绑的libzip"警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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:

警告:不建议使用捆绑的libzip,并将其删除.
配置:警告:某些功能(例如加密和bzip2)不可用.
配置:警告:使用系统库,并且--with-libzip是 推荐.

WARNING: Use of bundled libzip is deprecated and will be removed.
configure: WARNING: Some features such as encryption and bzip2 are not available.
configure: WARNING: Use system library and --with-libzip is recommended.

在没有这些警告的情况下安装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不再捆绑了安装它.您安装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"警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆