I try to install GD, because I'm getting the error "Call to undefined function imagecreatefromjpeg()".
When building the image I'm getting the error
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
My 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
What's the right way to install GD?
What about running apt-get update
first to update local list of packages? It should always be run before installing:
FROM php:7-fpm
RUN apt-get update && apt-get install --yes libfreetype6-dev ....
According to offical image doc :
If you are having difficulty figuring out which Debian or Alpine packages need to be installed before docker-php-ext-install, then have a look at the install-php-extensions project. to install the GD extension you simply have to add these to lines to Dockerfile and get ride of everty things:
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions gd
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.