How to add php-redis for a dockerfile of laravel to kubernetes? How to add php-redis for a dockerfile of laravel to kubernetes? kubernetes kubernetes

How to add php-redis for a dockerfile of laravel to kubernetes?


Since you are using official PHP docker image, you can install php-redis extension via PECL:

RUN pecl install redis \    && docker-php-ext-enable redis

Simple as that!

You can learn more about installing PHP extensions from official PHP docker docs (in case of php-redis, installing PECL extensions).

So in your case, RUN command can look something like this:

# Your PHP DockerfileRUN apk add --no-cache --virtual .build-deps \        $PHPIZE_DEPS \        curl \        libtool \        libxml2-dev \    && apk add --no-cache \        curl \        git \        mysql-client \    && pecl install redis \     # install redis extension via PECL    && docker-php-ext-install \        mbstring \        pdo \        pdo_mysql \        tokenizer \        bcmath \        opcache \        xml \    && apk del -f .build-deps \    && docker-php-ext-enable \       pdo_mysql \       redis                    # don't forget to enable redis extension


Update for alpine php 7.3.5

RUN apk add --no-cache pcre-dev $PHPIZE_DEPS \        && pecl install redis \        && docker-php-ext-enable redis.so