Dockerfile文件内容:
# 从官方基础版本构建
FROM php:7.3.7-fpm
# 官方版本默认安装扩展:
# Core, ctype, curl
# date, dom
# fileinfo, filter, ftp
# hash
# iconv
# json
# libxml
# mbstring, mysqlnd
# openssl
# pcre, PDO, pdo_sqlite, Phar, posix
# readline, Reflection, session, SimpleXML, sodium, SPL, sqlite3, standard
# tokenizer
# xml, xmlreader, xmlwriter
# zlib
# 更新为国内镜像
COPY zhongkeda.list /etc/apt/sources.list
RUN apt-get update
# bcmath, calendar, exif, gettext, sockets, dba,
# mysqli, pcntl, pdo_mysql, shmop, sysvmsg, sysvsem, sysvshm 扩展
RUN docker-php-ext-install -j$(nproc) bcmath calendar exif gettext sockets dba mysqli pcntl pdo_mysql shmop sysvmsg sysvsem sysvshm iconv
# GD 扩展
RUN apt-get install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
# redis 扩展
RUN pecl install redis-5.0.0 && docker-php-ext-enable redis
# opcache 扩展
RUN docker-php-ext-configure opcache --enable-opcache && docker-php-ext-install opcache
# xdebug 扩展
RUN pecl install xdebug-2.7.2 && docker-php-ext-enable xdebug
# swoole 扩展
RUN pecl install swoole-4.4.0 && docker-php-ext-enable swoole
# yaf 扩展
RUN pecl install yaf-3.0.8 && docker-php-ext-enable yaf
# 镜像信息
LABEL Author="Stone"
LABEL Version="2019.7"
LABEL Description="PHP 7.3.7 开发环境镜像."
zhongkeda.list文件内容:
deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free
deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free
启动
docker build -t php73 .
//启动一次
docker run --name php73 -d \
-v /data/code:/data/code \
-v /data/soft/lnmp/php73/etc:/usr/local/etc \
-p 9000:9000 \
php73
//把php配置文件复制出来
docker cp php73:/usr/local/etc /data/soft/lnmp/php73/etc
// /data/code/ 代码目录 /data/soft/lnmp/php73/etc php配置文件目录
docker run --name php73 -d \
-v /data/code:/data/code \
-v /data/soft/lnmp/php73/etc:/usr/local/etc \
-p 9000:9000 \
php73