Status: Downloaded newer image for php:7.2-rc-fpm
---> 008dcb3cc91c
Step 2/12 : RUN apt-get update \
&& apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmemcached-dev \
libpng12-dev \
sendmail \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd mbstring mcrypt pdo pdo_mysql \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug
---> Running in 3ab392bcb4c8
Get:1 http://security.debian.org stretch/updates InRelease [62.9 kB]
Get:3 http://security.debian.org stretch/updates/main amd64 Packages [189 kB]
Ign:2 http://cdn-fastly.deb.debian.org/debian stretch InRelease
Get:4 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [88.5 kB]
Get:5 http://cdn-fastly.deb.debian.org/debian stretch Release [118 kB]
Get:6 http://cdn-fastly.deb.debian.org/debian stretch Release.gpg [2373 B]
Get:7 http://cdn-fastly.deb.debian.org/debian stretch/main amd64 Packages [9497 kB]
Fetched 9958 kB in 4s (2019 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package libpng12-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libpng12-dev' has no installation candidate
ERROR: Service 'php_fpm' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libmemcached-dev libpng12-dev sendmail && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd mbstring mcrypt pdo pdo_mysql && pecl install xdebug && docker-php-ext-enable xdebug' returned a non-zero code: 100
I believe the package you really want is simply "libpng-dev" (
https://packages.debian.org/stretch/libpng-dev).
That's possible but it worked for 7.0 and 7.1 and the doc from https://hub.docker.com/_/php/ needs to be updated if that is the case:

Yes, they're based on different versions of Debian, so some of the package
names have to shift accordingly.
libpng-dev appears to be a virtual package in debian jessie, which results in libpng12-dev being installed.
It seems the documentation can be changed to state libpng-dev as the dependency / package to install (and this will work for Jessie and Stretch)?
Yeah, if it works that'd be an excellent change!
See also https://github.com/docker-library/php/issues/504, which is a discussion regarding the base images of each PHP version.
Verified that the swap to libpng-dev works and applied to the documentation in https://github.com/docker-library/docs/commit/b48ce3c87718b700746e45ee9ef45c4bf8c75d52. Thanks for the suggestion, @ehuggett!
Hello, having the same issue, if I try libpng12-dev I get : E: Package 'libpng12-dev' has no installation candidate
If I try libpng-dev I get: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20160303/gd.so' - libpng16.so.16: cannot open shared object file: No such file or directory in Unknown on line 0
Any ideas? Thanks!
@alexsabau86 did you apt-get purge --auto-remove libpng-dev after using docker-php-ext-install? Unless you specifically also installed libpng16-16 it would be removed in the purge and thus the .so would be missing.
Most helpful comment
I believe the package you really want is simply "libpng-dev" (
https://packages.debian.org/stretch/libpng-dev).