Skip to content

Installing php5-gd with apt-get inside php:5.6-apache container #215

@keltik85

Description

@keltik85

I need to install the php extension php5-gd.

I tried to do it by using this Dockerfile:

FROM php:5.6-apache
MAINTAINER "Phuc Dat <phucdat@bi.ch>"
COPY ./templates/apache2files/piwik /var/www/html/
COPY ./templates/php.ini /usr/local/etc/php/
RUN chmod 777 -R /var/www/html/
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install php5-gd

Giving me the following error:

error: /usr/src/php/ext/php5-gd does not exist

usage: /usr/local/bin/docker-php-ext-install [-jN] ext-name [ext-name ...]
   ie: /usr/local/bin/docker-php-ext-install gd mysqli
       /usr/local/bin/docker-php-ext-install pdo pdo_mysql
       /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name:
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mcrypt mssql mysql mysqli oc                                       i8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop sim                                       plexml snmp soap sockets spl standard sybase_ct sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip

Then I changed the Dockerfile to this, which installed the extension:

FROM php:5.6-apache
MAINTAINER "Phuc Dat <phucdat@bi.ch>"
COPY ./templates/apache2files/piwik /var/www/html/
COPY ./templates/php.ini /usr/local/etc/php/
RUN chmod 777 -R /var/www/html/
RUN docker-php-ext-install mysqli
RUN docker-php-ext-install mbstring
RUN apt-get update && \
        apt-get install -y php5-gd && \
        rm -r /var/lib/apt/lists/*

I can double check that the library is installed using:

[root@localhost ~]# docker exec -it mypiwikcontainer bash
root@4ddd1ce105a6:/var/www/html# dpkg -l php5-gd
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                          Version                     Architecture                Description
+++-=============================================-===========================-===========================-===============================================================================================
ii  php5-gd                                       5.6.19+dfsg-0+deb8u1        amd64                       GD module for php5

But I can see that the php5-gd is not loaded into the apache2 instance in my container:

[root@localhost ~]# docker exec -it mypiwikcontainer bash
root@4ddd1ce105a6:/var/www/html# php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

To actually load it into the apache2 instance in the container, I tried this:

[root@localhost ~]# docker exec -it piwikcontainer bash
root@4ddd1ce105a6:/var/www/html# apachectl restart

and also this:

[root@localhost ~]# docker exec -it piwikcontainer bash
root@4ddd1ce105a6:/var/www/html# /etc/init.d/apache2 restart

Both approaches didn't work.

This all leads to the question:

How can I get php5-gd extension working inside the php:5.6-apache container?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions