dockerfile创建php容器(含有memcached、redis、gd、xdebug扩展)
代码如下:
1 FROM php:7.2-fpm 2 COPY redis-3.1.6.tgz /home/redis-3.1.6.tgz 3 COPY memcached-3.0.4.tgz /home/memcached-3.0.4.tgz 4 COPY xdebug-2.6.0.tgz /home/xdebug-2.6.0.tgz 5 RUN apt-get update && apt-get install -y \ 6 libfreetype6-dev \ 7 libjpeg62-turbo-dev \ 8 libmcrypt-dev \ 9 libpng-dev \10 libz-dev libmemcached-dev \11 && docker-php-ext-install gd \12 && docker-php-ext-install pdo_mysql \13 && pecl install redis-3.1.6.tgz && echo "extension=redis.so" > /usr/local/etc/php/conf.d/redis.ini \14 && pecl install memcached-3.0.4.tgz && echo "extension=memcached.so" > /usr/local/etc/php/conf.d/memcached.ini \15 && rm -r /home/memcached-3.0.4.tgz \16 && tar -xf /home/xdebug-2.6.0.tgz \17 && rm -rf /home/xdebug-2.6.0.tgz \18 && mkdir -p /usr/src/php/ext \19 && mv xdebug-2.6.0 /usr/src/php/ext/xdebug \20 && docker-php-ext-install xdebug \21 && rm -rf /home/redis-3.1.6.tgz22 WORKDIR /opt23 RUN usermod -u 1000 www24 VOLUME ["/opt"]
使用了两种方式安装扩展
docker-php-ext-installpecl install