8
votes

I tried to install some needed extensions for php using docker.

Here is my Dockerfile :

FROM php:7-fpm

RUN apt-get update && apt-get install -y \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng12-dev \
    libsqlite3-dev \
    libssl-dev \
    libcurl3-dev \
    libxml2-dev \
    libzzip-dev \
&& docker-php-ext-install iconv json mcrypt mbstring mysql mysqli pdo_mysql pdo_sqlite phar curl ftp hash session simplexml tokenizer xml xmlrpc zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd

WORKDIR /var/www

CMD ["php7-fpm"]

And here is the error I got :

error: /usr/src/php/ext/mysql 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 mysqli oci8 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 simplexml snmp soap sockets spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip

ERROR: Service 'php-localdev' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12-dev libsqlite3-dev libssl-dev libcurl3-dev libxml2-dev libzzip-dev && /usr/local/bin/docker-php-ext-install iconv json mcrypt mbstring mysql mysqli pdo_mysql pdo_sqlite phar curl ftp hash session simplexml tokenizer xml xmlrpc zip && /usr/local/bin/docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && /usr/local/bin/docker-php-ext-install gd'

returned a non-zero code: 1

Do you see any issues in my Dockerfile, or the problem is elsewhere ?

I was inspired for this Dockerfile by the php docker hub.

Thansk for your help.

1

1 Answers

9
votes

In the error output, it lists the possible values for ext_name. mysql isn't listed. There is mysqli and pdo_mysql, but not mysql. Your command does include mysql, and the first line of the error seems to be complaining about that. Try taking that out and see if that works.