docker run --name nginx-man -it centos 创建一个centos
yum install -y wget gcc gcc-c++ make openssl-devel 构建环境
wget http://nginx.org/download/nginx-1.14.0.tar.gz 获取nginx安装包
wget https://ftp.pcre.org/pub/pcre/pcre2-10.23.tar.gz --no-check-certificate
获取pcre
tar zxf nginx-1.14.0.tar.gz
tar zxf pcre2-10.23.tar.gz 解压两个包
cd nginx-1.14.0
useradd -s /sbin/nologin -M www
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-pcre=/usr/local/src/pcre2-10.23
make
make install
vi /usr/local/src/nginx-1.14.0/conf/nginx.conf 写入daemon off;
exit
docker commit -m "my nginx" 335573f3663c sjw/my-nginx:v1 创建一个自己的nginx镜像,在启动时,自动启动nginx
docker run -d -p 92:80 sjw/my-nginx:v1 /usr/local/nginx/sbin/nginx 启动docker
原文地址:https://www.cnblogs.com/shejiewei/p/9865490.html