phpdockerdebiangdphp-5.6

Can't install php5.6-gd in docker container


I want to create a container with php5.6-fpm but when I run it, PHP there doesn't have such needed extensions as e.g. gd and some others needed for wordpress. I want to install it manually inside the container fpm. docker exec -it fpm bash It turns out that Debian 9 installed there and I can't install php5.6-gd for E: Package 'php5.6-gd' has no installation candidate! I tried adding ondrej repository, but it's not helpful at all.

Is there any other ways to get container with php5.6-fpm installed and add some extension to it?


Solution

  • Here you can find working Dockerfile for what you need.

    Relevant part:

    FROM php:5.6-fpm
    (...)
    RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        curl \
        libmemcached-dev \
        libz-dev \
        libpq-dev \
        libjpeg-dev \
        libpng12-dev \
        libfreetype6-dev \
        libssl-dev \
        libmcrypt-dev
    
    (...)
    # Install the PHP gd library
    RUN docker-php-ext-install gd && \
        docker-php-ext-configure gd \
            --enable-gd-native-ttf \
            --with-jpeg-dir=/usr/lib \
            --with-freetype-dir=/usr/include/freetype2 && \
        docker-php-ext-install gd