Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning
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.
For PHP < 7.3, you then need to
docker-php-ext-configure zip --with-libzip
before performing the installation with
docker-php-ext-install zip
as the last warning indicates.
In short: change the relevant part of your Dockerfile to
For 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
For 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.
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
I built a PHP container on Docker using php:7.2-fpm-alpine
FROM php:7.2-fpm-alpine
WORKDIR /var/www
RUN apk add --no-cache zip libzip-dev
RUN docker-php-ext-configure zip --with-libzip
RUN docker-php-ext-install zip
RUN docker-php-ext-install pdo pdo_mysql
In case you are using 7.4 this worked for me:
FROM php:7.4-fpm-alpine
RUN apk add --no-cache zip libzip-dev
RUN docker-php-ext-configure zip
RUN docker-php-ext-install zip
RUN docker-php-ext-install pdo pdo_mysql