Docker php 添加 Zip 扩展
Docker php adding Zip Extension
我正在尝试安装从 php:7.4-fpm-alpine
构建的 PHP 容器的 Zip 扩展
这就是我在 Dockerfile
中使用的内容
RUN apk add --no-cache zip libzip-dev
RUN docker-php-ext-configure zip --with-libzip=/usr/include
RUN docker-php-ext-install zip
但它给我这个错误:
configure: error: unrecognized options: --with-libzip ERROR: Service
'php' failed to build : The command '/bin/sh -c
docker-php-ext-configure zip --with-libzip=/usr/include' returned a
non-zero code: 1
The solution is as simple as removing the docker-php-ext-configure zip --with-libzip
line entirely for PHP >= 7.4. Defaults are sufficient.
如评论者hackel on their issue tracker: https://github.com/laradock/laradock/issues/2421#issuecomment-567728540
所以一个有效的 Dockerfile 将是:
FROM php:7.4-fpm-alpine
RUN apk add --no-cache \
libzip-dev \
zip \
&& docker-php-ext-install zip
试试这个
FROM composer AS composer
COPY . /app
RUN rm composer.lock && composer install \
--optimize-autoloader \
--no-interaction \
--no-progress \
--ignore-platform-reqs
RUN apk add --no-cache php \
php7-common \
php7-fpm \
php7-pdo \
php7-opcache \
php7-zip \
如果使用 php:7.4-fpm
试试这个
FROM php:7.4-fpm
# Install system dependencies
RUN apt-get update && apt-get install -y zip
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-configure zip \
&& docker-php-ext-install zip
我正在尝试安装从 php:7.4-fpm-alpine
这就是我在 Dockerfile
中使用的内容RUN apk add --no-cache zip libzip-dev
RUN docker-php-ext-configure zip --with-libzip=/usr/include
RUN docker-php-ext-install zip
但它给我这个错误:
configure: error: unrecognized options: --with-libzip ERROR: Service 'php' failed to build : The command '/bin/sh -c docker-php-ext-configure zip --with-libzip=/usr/include' returned a non-zero code: 1
The solution is as simple as removing the
docker-php-ext-configure zip --with-libzip
line entirely for PHP >= 7.4. Defaults are sufficient.
如评论者hackel on their issue tracker: https://github.com/laradock/laradock/issues/2421#issuecomment-567728540
所以一个有效的 Dockerfile 将是:
FROM php:7.4-fpm-alpine
RUN apk add --no-cache \
libzip-dev \
zip \
&& docker-php-ext-install zip
试试这个
FROM composer AS composer
COPY . /app
RUN rm composer.lock && composer install \
--optimize-autoloader \
--no-interaction \
--no-progress \
--ignore-platform-reqs
RUN apk add --no-cache php \
php7-common \
php7-fpm \
php7-pdo \
php7-opcache \
php7-zip \
如果使用 php:7.4-fpm
试试这个FROM php:7.4-fpm
# Install system dependencies
RUN apt-get update && apt-get install -y zip
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-configure zip \
&& docker-php-ext-install zip