vim dockerfile
FROM centos:7
ADD nginx-1.18.0.tar.gz /root/
RUN yum -y install make gcc pcre-devel zlib-devel php php-mysql php-gd php-fpm
&& cd /root/nginx-1.18.0
&& ./configure
&& make
&& make install
&& echo “<?php phpinfo(); ?>” > /usr/local/nginx/html/index.php
COPY nginx.conf /usr/local/nginx/conf/nginx.conf
COPY php.sh /usr/bin
CMD [“php.sh”]
php.sh内容
#! /bin/bash
/usr/local/nginx/sbin/nginx
exec php-fpm -F
执行dockerfile
docker build -t lnmp:1.1 ./
查看镜像 docker images
基于镜像创建一个容器
docker run --name -d -p lnmp 80:80 lnmp:1.1