在docker错误下调用未定义函数Intervention \ Image \ Gd \ imagecreatefromjpeg

时间:2018-12-27 08:58:42

标签: docker laravel-5 jpeg

我尝试将我的laravel 5.7.19应用程序安装在docker(version:'3.1',)下并运行一些页面,但出现错误:

Call to undefined function Intervention\Image\Gd\imagecreatefromjpeg()

我在web / Dockerfile.yml中包含jpeg支持:

FROM php:7.2-apache

RUN apt-get update -y && apt-get install -y libpng-dev libjpeg-dev libxpm-dev libfreetype6-dev  nano  \
    && docker-php-ext-configure gd \
    --with-freetype-dir=/usr/include/ \
    --with-jpeg-dir=/usr/include/ \
    --with-xpm-dir=/usr/include/ \
    --with-vpx-dir=/usr/include/

RUN docker-php-ext-install \
    pdo_mysql \
    && a2enmod \
    rewrite


RUN docker-php-ext-install gd

但是我还是有同样的错误。路径“ / usr / include /”是否有效以及如何检查?

我正在使用的操作系统是Kubuntu 18 ...

谢谢!

1 个答案:

答案 0 :(得分:0)

您需要添加到Dockerfile.yml文件中,包括gd和类型格式,如:

FROM php:7.2-apache

RUN apt-get update && \
    apt-get install -y \
    libfreetype6-dev \
    libwebp-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    nano \
    libgmp-dev \
    libldap2-dev \
    netcat \
    sqlite3 \
    libsqlite3-dev && \
    docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/  --with-jpeg-dir=/usr/include/ && \
    docker-php-ext-install gd pdo pdo_mysql pdo_sqlite zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite

那一定有帮助。