# 前言
记录下自己 docker 下常用的 php 环境构建,可以上传的 docker 镜像仓库
因为构建还挺耗时的
# 具体代码
| FROM php:7.1.13-fpm |
| |
| RUN echo "deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib" > /etc/apt/sources.list \ |
| && echo "deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib" >> /etc/apt/sources.list \ |
| && echo "deb http://mirrors.aliyun.com/debian-security stretch/updates main" >> /etc/apt/sources.list \ |
| && echo "deb-src http://mirrors.aliyun.com/debian-security stretch/updates main" >> /etc/apt/sources.list \ |
| && echo "deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list \ |
| && echo "deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib" >> /etc/apt/sources.list \ |
| && echo "deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list \ |
| && echo "deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" >> /etc/apt/sources.list \ |
| && rm -f /etc/apt/sources.list.d/* \ |
| && docker-php-ext-install pdo_mysql mysqli \ |
| && apt-get update && apt-get install -y \ |
| libfreetype6-dev \ |
| libjpeg62-turbo-dev \ |
| libpng-dev \ |
| pkg-config \ |
| libssl-dev \ |
| && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include \ |
| && docker-php-ext-install -j$(nproc) gd pcntl bcmath |
| |
| RUN pecl install https://pecl.php.net/get/swoole-4.5.10.tgz \ |
| && pecl install redis \ |
| && pecl install mongodb \ |
| && docker-php-ext-enable swoole redis mongodb |
| |
| CMD ["php-fpm"] |
# docker 组合命令
| |
| docker ps -a | grep Exited | cut -d' ' -f1 | xargs docker start |
| docker ps -a | grep Exited | awk '{print $1}' | xargs docker start |