Docker调用未定义的函数imagecreatefromjpeg()

时间:2018-12-28 10:44:45

标签: php docker

我尝试安装GD,因为出现错误“调用未定义的函数imagecreatefromjpeg()”。

构建图像时出现错误

E: Unable to locate package libfreetype6-dev
E: Unable to locate package libjpeg62-turbo-dev
E: Unable to locate package libpng12-dev
The command '/bin/sh -c apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev && docker-php-ext-configure gd --enable-gd-native-ttf --with-freetype-dir=/usr/include/freetype2 --with-png-dir=/usr/include --with-jpeg-dir=/usr/include && docker-php-ext-install gd && docker-php-ext-enable gd' returned a non-zero code: 100

我的Dockerfile

FROM php:7-fpm

# Install GD
RUN apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng12-dev \
&& docker-php-ext-configure gd \
--enable-gd-native-ttf \
--with-freetype-dir=/usr/include/freetype2 \
--with-png-dir=/usr/include \
--with-jpeg-dir=/usr/include \
&& docker-php-ext-install gd \
&& docker-php-ext-enable gd

安装GD的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

首先运行apt-get update以更新本地软件包列表怎么办?它应该始终在安装之前运行:

FROM php:7-fpm
RUN apt-get update && apt-get install --yes libfreetype6-dev ....