为什么gd配置失败?错误:无法识别的选项:--with-gd,--with-png

Ric*_*lev 4 php docker dockerfile

我为需要部署的 Php 代码创建了自己的 Dockerfile。由于篇幅限制,我只展示了它的开头

FROM php:7.4-fpm

WORKDIR /var/www
RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libonig-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl \
    libzip-dev
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-png=/usr/include/
RUN docker-php-ext-install gd
Run Code Online (Sandbox Code Playgroud)

我收到错误

Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
configure: error: unrecognized options: --with-gd, --with-png
The command '/bin/sh -c docker-php-ext-configure gd --with-gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ --with-png=/usr/include/' returned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)

我应该改变什么?

cet*_*ver 14

从 PHP 7.4.0 开始,--with-gd变为--enable-gd

https://www.php.net/manual/en/image.installation.php

这不是强制性的,例如:

RUN apt-get --yes install libfreetype6-dev \
                          libjpeg62-turbo-dev \
                          libpng-dev \
                          libwebp-dev 

RUN set -e; \
    docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype; \
    docker-php-ext-install -j$(nproc) gd
Run Code Online (Sandbox Code Playgroud)