How to install php-redis extension using the official PHP Docker image approach?

starikovs picture starikovs · Jul 12, 2015 · Viewed 58.6k times · Source

I want to build my PHP-FPM image with php-redis extension based on the official PHP Docker image, for example, using this Dockerfile: php:5.6-fpm.

The docs say that I can install extensions this way, installing dependencies for extensions manually:

FROM php:5.6-fpm
# Install modules (iconv, mcrypt and gd extensions)
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    && docker-php-ext-install iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd
CMD ["php-fpm"]

Without Docker I installed it with apt-get install php5-redis. But how can I install it using the approach above?

Answer

TimWolla picture TimWolla · Jul 12, 2015

Redis is not an extension that is included in “php-src”, therefore you cannot use docker-php-ext-install. Use PECL:

RUN pecl install -o -f redis \
&&  rm -rf /tmp/pear \
&&  docker-php-ext-enable redis