Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

Under docker error Call to undefined function Intervention\Image\Gd\imagecreatefromjpeg

Hello, I try to install my laravel 5.7.19 application under docker and running some pages I got error:

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

I include jpeg files in web/Dockerfile.yml:

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

But I have the same error anyway. Is path “/usr/include/” valid and how to check it ?

My working OS is Kubuntu 18...

Thanks!

0 likes
6 replies
bobbybouwmann's avatar

It seems that you have the correct syntax here. I don't see anything else missing at the moment.

Source: https://docs.docker.com/samples/library/php/#php-core-extensions

However I believe you need some extra dependencies before you can run docker-php-ext-configure. You can find a more detailed answer here: https://stackoverflow.com/questions/37527803/how-to-install-extension-for-php-via-docker-php-ext-install#answer-37527960

Let me know if that works for you!

mstdmstd's avatar

Thank you for your feedback! I tried to remade web/Dockerfile.yml according to your links and I got file :

FROM php:7.2-apache

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        nano \
        libjpeg62-turbo-dev \
        libpng-dev \
        libmcrypt-dev \
        libicu-dev \
        libxml2-dev \
    && docker-php-ext-install -j$(nproc) iconv \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

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

and running command :

docker-compose up -d --build

I got warning(I suppose it is not critical)

warning: gd (gd.so) is already loaded!

I checked logs and found no errors :

docker logs --tail=20  votes_docker_web_1
docker logs --tail=20  votes_docker_db_1
docker logs --tail=20  votes_docker_phpmyadmin_1
docker logs --tail=20  votes_docker_composer_1   

I check modules installed in the box and see gd installed:

# php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

But anyway opening the project in browser I got error:

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

Did I miss something in commands of web/Dockerfile.yml ?

bobbybouwmann's avatar

Not sure if you need enable the GD module as well in the php.ini file. However I expect that this is not needed because it's a module you install. I currently can't think of anything else that could fix this for you.

ohffs's avatar

I've got a docker image with GD installed - try this part :

FROM php:7.2-apache

RUN apt-get update && \
    apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libgmp-dev libldap2-dev netcat sqlite3 libsqlite3-dev && \
    docker-php-ext-configure gd --with-freetype-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

If that doesn't help - try doing a call to phpinfo() and see if GD is showing has having jpeg support - I seem to remember it can be a bit picky about the order you do things in :-/

1 like
mstdmstd's avatar

@OHFFS - Thanks! But next I got error :

Unsupported image type. GD/PHP installation does not support WebP format.

But I do not use any WebP files in my app. Which extentions these files mut be? Or how to fix this error?

ohffs's avatar
ohffs
Best Answer
Level 50

@MSTDMSTD - It looks like that should only happen if you're loading a webp file (from a quick look at the sourcecode). There is a stackoverflow answer that might help get webp installed which might get the error to go away though ;-)

1 like

Please or to participate in this conversation.