dockerfile创建php容器(含有memcached、redis、gd、xdebug扩展)
代码如下:FROM php:7.2-fpm
COPY redis-3.1.6.tgz /home/redis-3.1.6.tgz
COPY memcached-3.0.4.tgz /home/memcached-3.0.4.tgz
COPY xdebug-2.6.0.tgz /home/xdebug-2.6.0.tgz
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng-dev \
libz-dev libmemcached-dev \
&& docker-php-ext-install gd \
&& docker-php-ext-install pdo_mysql \
&& pecl install redis-3.1.6.tgz && echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini \
&& pecl install memcached-3.0.4.tgz && echo "extension=memcached.so" > /usr/local/etc/php/conf.d/memcached.ini \
&& rm -r /home/memcached-3.0.4.tgz \
&& tar -xf /home/xdebug-2.6.0.tgz \
&& rm -rf /home/xdebug-2.6.0.tgz \
&& mkdir -p /usr/src/php/ext \
&& mv xdebug-2.6.0 /usr/src/php/ext/xdebug \
&& docker-php-ext-install xdebug \
&& rm -rf /home/redis-3.1.6.tgz
WORKDIR /opt
RUN usermod -u 1000 www
VOLUME ["/opt"]
使用了两种方式安装扩展
docker-php-ext-install
pecl install