手动构建docker镜像
手动构建docker nginx镜像
yum install wget gcc gcc-c++ make openssl-devel
Wget http://nginx.org/download/nginx-1.15.5.tar.gz 下载nginx
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz 下载pcre依赖
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/pcre-8.38
配置用户
在make一下 make之后make install
设置开机自动运行nginx
vi /etc/rc.local
加上 /usr/local/nginx/sbin/nginx
要把nginx放在前台运行
vi /usr/local/nginx/conf/nginx.conf
第一行加上daemon off;
在退出docker
提交镜像 docker commit -m “nginx-man” 381ff42eb0c8 tp/my-nginx:v1 (提交之后会返回一个id)
Docker image一下就可以看到刚刚自己创建的镜像
跑一下试试 docker run -d -p xx(外部端口号):docker本地的端口号 xxx(name) /usr/local/nginx/sbin/nginx
在ip+刚刚配置的端口访问一下成功!