Help us understand the problem. What is going on with this article?

PHPのオフィシャルDockerイメージにredis exensionを追加する方法

More than 3 years have passed since last update.

DockerのOfficialイメージで、追加のextensionをインストールする方法としては

Dockerfile
RUN docker-php-ext-install pdo

とすればOKですが、redisのextensionをインストールするときは、単純に

Dockerfile
RUN docker-php-ext-install redis

ではインストールできません。

ネットに上がっている情報そのままではNGだったので、いろいろいじってやっと通った方法を個人的備忘録。

結論

Dockerfile
FROM php:7.1.2-fpm-alpine

RUN apk update && \
    apk --no-cache upgrade && \
    docker-php-source extract && \
    curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/php7.tar.gz && \
    tar xfz /tmp/redis.tar.gz -C /tmp && \
    rm -r /tmp/redis.tar.gz && \
    mv /tmp/phpredis-php7 /usr/src/php/ext/redis && \
    docker-php-ext-install redis <その他exension...>

ポイントはdocker-php-source extractを明示的に実行すること。
これをやらないと/usr/src/php/extディレクトリが作成されないので、mv /tmp/phpredis-php7 /usr/src/php/ext/redisが失敗します。

ここにたどり着くまで3時間を費やしてしまった…。

hirohero
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした