&& rm -rf /var/lib/apt/lists/*
# 把构建上下文目录conf,即Dockerfile/centos.bz/nginx/conf目录下的文件复制到容器的/usr/local/nginx/conf目录。
COPY conf/ /usr/local/nginx/conf/
# 定义启动容器时运行的命令
ENTRYPOINT ["/usr/local/nginx/sbin/nginx"]
EXPOSE 80 443
对于conf目录下的nginx配置文件,需要把日志,网站目录更改为以下约定的目录位置。
php-fpm Dockerfile
创建Dockerfile/centos.bz/php-fpm目录,在此目录下创建Dockerfile文件,内容如下:
FROM debian:jessie
LABEL maintainer "admin@centos.bz"# 定义软件版本,编译工具,依赖等变量
ENV PHP_VERSION 5.6.30
ENV BUILD_TOOLS m4
autoconf
autoconf2.13
openssl
wget
gcc
make
ENV BUILD_DEPS libcurl4-gnutls-dev
libxml2-dev
zlib1g-dev
libpcre3-dev
libjpeg-dev
libpng12-dev
libfreetype6-dev
libmhash-dev
libmcrypt-dev
libssl-dev
libtool
ENV PHP_LOCATION /usr/local/php
ENV BUILD_ARG --prefix=${PHP_LOCATION}
--with-config-file-path=${PHP_LOCATION}/etc
--enable-fpm
--enable-bcmath
--with-pdo_sqlite
--with-gettext
--with-iconv
--enable-ftp
--with-sqlite3
--enable-mbstring
--enable-sockets
--enable-zip
--enable-soap
--with-openssl
--with-zlib
--with-curl
--with-gd
--with-jpeg-dir
--with-png-dir
--with-freetype-dir
--with-mcrypt
--with-mhash
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--without-pear
--with-libdir=lib64
--enable-opcache
--disable-cgi
ENV SRC_DIR /opt/php
WORKDIR ${SRC_DIR}
# 开始编译安装php
RUN apt-get update
&& apt-get -y --no-install-recommends install ${BUILD_DEPS} ${BUILD_TOOLS}
&& wget http://php.net/distributions/php-${PHP_VERSION}.tar.gz
&& tar xf php-${PHP_VERSION}.tar.gz
&& cd php-${PHP_VERSION}
&& ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.so
&& ln -s /usr/lib /usr/lib64
&& ./configure ${BUILD_ARG}
&& make -j$(nproc)
&& make install
&& cp php.ini-production ${PHP_LOCATION}/etc/php.ini
&& cp ${PHP_LOCATION}/etc/php-fpm.conf.default ${PHP_LOCATION}/etc/php-fpm.conf
&& rm -rf ${SRC_DIR}
&& apt-get purge -y --auto-remove ${BUILD_TOOLS}
&& rm -rf /var/lib/apt/lists/*
WORKDIR ${PHP_LOCATION}/etc/
# 配置php-fpm,即使用sed工具编辑php-fpm.conf和php.ini文件,这里的php-fpm相关配置命令不与上面的编译命令合在一起来减小层数是因为










