调用未定义函数 Intervention\Image\Gd\imagecreatefromjpeg() Laravel 8 + Docker 桌面 4.4.4

Mis*_*h90 5 gd libjpeg docker-desktop php-8 laravel-8

这是我的泊坞窗文件:

FROM php:8.0-fpm-buster

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    curl \
    libpng-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    jpegoptim optipng pngquant gifsicle \
    libonig-dev \
    libxml2-dev \
    zip \
    sudo \
    unzip \
    npm \
    nodejs \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
Run Code Online (Sandbox Code Playgroud)

但我有一个错误

调用未定义函数 Intervention\Image\Gd\imagecreatefromjpeg()

当我尝试上传 jpg 图像时。即使我将其更改为:

docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-gd --with-freetype --with-jpeg \
Run Code Online (Sandbox Code Playgroud)

但我在构建时出现以下错误,并且在 Laravel 中出现上述错误

配置:错误:无法识别的选项:--with-freetype-dir、--with-jpeg-dir、--with-gd ------ 无法解决:rpc 错误:代码 = 未知 desc = 执行程序运行失败 [ /bin/sh -c apt-get update && apt-get install -y
build-essential git curl libpng-dev libjpeg-dev
libfreetype6-dev libjpeg62-turbo-dev jpegoptim optipng pngquant gifsicle libonig-dev libxml2-dev zip sudo
unzip npm nodejs && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-gd --with-freetype --with- jpeg && docker-php-ext-install -j$(nproc) gd]: 退出代码: 1

我怎样才能解决这个问题?

Mis*_*h90 16

我通过启用 GD 库来修复它,这是我的 Dockerfile 配置:

FROM php:8.0-fpm-buster

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    curl \
    libpng-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libgd-dev \
    jpegoptim optipng pngquant gifsicle \
    libonig-dev \
    libxml2-dev \
    zip \
    sudo \
    unzip \
    npm \
    nodejs

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
Run Code Online (Sandbox Code Playgroud)