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 获取pcretar zxf nginx-1.14.0.tar.gztar zxf pcre2-10.23.tar.gz 解压两个包cd nginx-1.14.0useradd -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 installvi /usr/local/src/nginx-1.14.0/conf/nginx.conf 写入daemon off;
exitdocker commit -m "my nginx" 335573f3663c sjw/my-nginx:v1 创建一个自己的nginx镜像,在启动时,自动启动nginxdocker run -d -p 92:80 sjw/my-nginx:v1 /usr/local/nginx/sbin/nginx 启动docker