Ich habe Probleme, wenn ich versuche, ein Bild mit imagecreatefromjpeg
zu erstellen, indem ich diesen Dockerfile
verwende, um den Container zu generieren:
FROM php:7.1-Apache
RUN apt-get update && \
apt-get install -y -qq git \
libjpeg62-turbo-dev \
apt-transport-https \
libfreetype6-dev \
libmcrypt-dev \
libpng12-dev \
libssl-dev \
Zip unzip \
nodejs \
npm \
wget \
vim
RUN pecl install redis && docker-php-ext-enable redis
RUN docker-php-ext-install -j$(nproc) iconv mcrypt Zip pdo pdo_mysql Gd bcmath
COPY ./containers/yii.conf /etc/Apache2/sites-available/000-default.conf
RUN for mod in rewrite headers; do a2enmod $mod; done && service Apache2 restart
WORKDIR /var/www/html/
Gd wurde korrekt installiert (auch libjpeg - beide erscheinen in php -i
Und phpinfo()
), aber imagecreatefromjpeg
funktioniert nicht und ich weiß nicht warum.
Ich habe auch apt install libjpeg-dev libpng-dev libfreetype6-dev
Ausgeführt, um eine Neuinstallation (oder Neukonfiguration) zu erzwingen, aber es scheint, dass dies nicht erfolgreich war (ja, ich starte auch den Container neu).
[email protected]:/var/www/html# php -i | grep -i Gd
/usr/local/etc/php/conf.d/docker-php-ext-Gd.ini,
Gd
GD Support => enabled
Gd Version => bundled (2.1.0 compatible)
Gd.jpeg_ignore_warning => 1 => 1
[email protected]:/var/www/html#
[email protected]:/var/www/html# docker-php-ext-enable Gd
warning: Gd (Gd.so) is already loaded!
[email protected]:/var/www/html#
Ich habe versucht apt install libgd2-xpm-dev*
Und anscheinend löst es das Problem nicht.
Ich fehlte zu setzen
RUN docker-php-ext-configure Gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) Gd
in mein Dockerfile.
Vollständig überarbeitetes Dockerfile:
FROM php:7.1-Apache
RUN apt-get update && \
apt-get install -y -qq git \
libjpeg62-turbo-dev \
apt-transport-https \
libfreetype6-dev \
libmcrypt-dev \
libpng12-dev \
libssl-dev \
Zip unzip \
nodejs \
npm \
wget \
vim
RUN pecl install redis && docker-php-ext-enable redis
RUN docker-php-ext-configure Gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install -j$(nproc) iconv mcrypt Zip pdo pdo_mysql Gd bcmath
COPY ./containers/yii.conf /etc/Apache2/sites-available/000-default.conf
RUN for mod in rewrite headers; do a2enmod $mod; done && service Apache2 restart
WORKDIR /var/www/html/
Für PHP 5.6
FROM php:5.6-Apache
RUN apt-get update && apt-get install -y \
libfreetype6-dev libjpeg62-turbo-dev \
libgd-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
Wenn immer noch nicht funktioniert, kann der Container neu installiert werden.
docker rm <container id>
docker-compose build --pull
docker-compose up