installing php-gd dependencies on alpine linux in php5-fpm-alpine docker container

Solution 1:

The package names in the example from docker hub are for the debian version. You must use the packages from alpine. You can search for alpine packages here: https://pkgs.alpinelinux.org/packages.

The following should work:

FROM php:5-fpm-alpine
RUN docker-php-ext-install mysqli
RUN apk upgrade --update && apk add \
  coreutils \
  freetype-dev \
  libjpeg-turbo-dev \
  libltdl \
  libmcrypt-dev \
  libpng-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