title: Troubles with Docker + PHP7 + GD resulting in "Call to undefined function imagecreatefromjpeg()"
body: <p>I'm having troubles when trying to create an image using <code>imagecreatefromjpeg</code> using this <code>Dockerfile</code> to generate the container:</p>
  <pre><code>FROM  php:7.1-apache
  
  RUN apt-get update &amp;&amp; \
      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 &amp;&amp; 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 &amp;&amp; service apache2 restart
  
  WORKDIR /var/www/html/
  </code></pre>
  <p>GD was correctly installed (libjpeg too - both appearing in <code>php -i</code> and <code>phpinfo()</code>) but <code>imagecreatefromjpeg</code> does not works and I don't know why.</p>
  <hr />
  <p>I also ran <code>apt install libjpeg-dev libpng-dev libfreetype6-dev</code> trying to ~force~ reinstallation (or reconfiguration) but seems doesn't succeded (yes, I also restart the container).</p>
  <pre><code>root@e8db647c96c4:/var/www/html# php -i | grep -i GD
  /usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
  gd
  GD Support =&gt; enabled
  GD Version =&gt; bundled (2.1.0 compatible)
  gd.jpeg_ignore_warning =&gt; 1 =&gt; 1
  root@e8db647c96c4:/var/www/html# 
  </code></pre>
  <hr />
  <pre><code>root@e8db647c96c4:/var/www/html# docker-php-ext-enable gd
  
  warning: gd (gd.so) is already loaded!
  
  root@e8db647c96c4:/var/www/html# 
  </code></pre>
  <hr />
  <p>I've tried <code>apt install libgd2-xpm-dev*</code> and apparently it doesn't solves the problem.</p>
  <hr />
  <h3>Solved</h3>
  <p>I was missing to put</p>
  <pre><code>RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
  RUN docker-php-ext-install -j$(nproc) gd
  </code></pre>
  <p>into my Dockerfile.</p>
  <hr />
  <p>Full revised Dockerfile:</p>
  <pre><code>FROM  php:7.1-apache
  
  RUN apt-get update &amp;&amp; \
      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 &amp;&amp; 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 &amp;&amp; service apache2 restart
  
  WORKDIR /var/www/html/
  </code></pre>