I have this in my Dockerfile of php container:
FROM php:7.0-fpm
# [...]
RUN apt-get update && apt-get install -y \
git \
unzip \
php7.0-gd
While building container, error occurs:
E: Unable to locate package php7.0-gd
Any idea how to install GD library because need it in my Symfony application?
Also tried and added to php Dockerfile:
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
Still got Exception in my Symfony 3 application:
if (!function_exists('gd_info')) {
throw new RuntimeException('Gd not installed');
}
I just had the same issue. Cleaning up the docker images and cache solved the problem (by using the install method from the documentation)
Yeah, if php7.0-gd worked it would be a package from Debian and not necessarily complied for the version of php built in the container (since it is pulled directly from upstream and built from source).
The second install is correct. If you don't need mcrypt, you could drop it.
$ docker run -it --rm php:7.0-fpm
root@c149f05d15a2:/var/www/html# apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng12-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
.....
root@c149f05d15a2:/var/www/html# php -i | grep gd
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
gd
gd.jpeg_ignore_warning => 1 => 1
root@c149f05d15a2:/var/www/html# php -a
Interactive shell
php > print function_exists('gd_info');
1
php > var_dump(gd_info());
array(12) {
["GD Version"]=>
string(26) "bundled (2.1.0 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(false)
["XBM Support"]=>
bool(true)
["WebP Support"]=>
bool(false)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
I have no idea, but it started to work. Maybe @dragosprotung was right. Thanks for help!
Most helpful comment
Yeah, if
php7.0-gdworked it would be a package from Debian and not necessarily complied for the version of php built in the container (since it is pulled directly from upstream and built from source).The second install is correct. If you don't need mcrypt, you could drop it.