Docker gd module for PHP 7
Asked Answered
V

3

6

I've got docker file, which is configured for Drupal 8, but after I fired up "docker-compose up", everything went smooth but in installation of Drupal it's showing me that "gd" module for PHP is not enabled.

here is my Dockerfile:

FROM php:7-fpm
# Install modules
RUN apt-get update

RUN apt-get install -y software-properties-common

RUN DEBIAN_FRONTEND="noninteractive" add-apt-repository ppa:ondrej/php

RUN apt-get update

RUN apt-get install -y vim curl wget build-essential software-properties-common git ca-certificates

RUN apt-get install -y \
    libbz2-dev \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng12-dev \
    libxpm-dev \
    libvpx-dev \
    libmcrypt-dev \
    libmemcached-dev \
    && \

apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \

docker-php-ext-configure gd \
        --with-freetype-dir=/usr/lib/x86_64-linux-gnu/ \
        --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/ \
        --with-xpm-dir=/usr/lib/x86_64-linux-gnu/ \
        --with-vpx-dir=/usr/lib/x86_64-linux-gnu/ \
    && \

docker-php-ext-install \
        bcmath \
        bz2 \
        exif \
        ftp \
        gd \
        gettext \
        mbstring \
        mcrypt \
        mysqli \
        opcache \
        pdo_mysql \
        shmop \
        sockets \
        sysvmsg \
        sysvsem \
        sysvshm \
        zip \
    && \

    pecl install apcu memcached && \
    echo 'extension = apcu.so' > /usr/local/etc/php/conf.d/apcu.ini && \
    echo 'extension = memcached.so' > /usr/local/etc/php/conf.d/memcached.ini

I try this method: Error In PHP5 ..Unable to load dynamic library But no use

Vestal answered 1/4, 2016 at 15:15 Comment(0)
L
16

This will help you

FROM php:7.0-fpm
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    && docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd
Laveta answered 16/1, 2017 at 18:23 Comment(3)
Funny, this worked out for me but I had to add it to the entrypoint. It didn't work at all if I let it as a RUN command inside the Dockerfile...Tigrinya
E: Package 'libpng12-dev' has no installation candidateCheekpiece
@Cheekpiece try apt-get install libpng-devUnable
P
7

maybe should try this

# Install GD
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd
Principal answered 24/6, 2016 at 4:55 Comment(1)
E: Unable to locate package libfreetype6-dev E: Unable to locate package libjpeg62-turbo-dev E: Unable to locate package libpng12-devSelectee
C
6

With PHP 7.2 I got the following error when trying the accepted/other answers:

E: Package 'libpng12-dev' has no installation candidate

This worked for me:

FROM php:7.2-fpm
RUN apt update \
    && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) intl pdo_mysql bcmath mbstring exif gd

Note the change from libpng-dev12 to libpng-dev

Cheliform answered 30/11, 2018 at 19:11 Comment(1)
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works. The command '/bin/sh -c apt update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install -j$(nproc) intl pdo_mysql bcmath mbstring exif gd' returned a non-zero code: 1Selectee

© 2022 - 2024 — McMap. All rights reserved.