cat dockerfile
FROM centos:7.6.1810
RUN mkdir /etc/yum.repos.d/bak /apps
RUN mv /etc/yum.repos.d/*repo /etc/yum.repos.d/bak
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
RUN yum clean all && yum makecache
RUN yum -y install gcc gcc-c++ zlib zlib-devel openssl openssl-devel pcre-devel unzip patch net-tools
RUN groupadd -r nginx
RUN useradd -s /sbin/nologin -g nginx -r nginx
RUN curl -o nginx-1.22.0.tar.gz http://nginx.org/download/nginx-1.22.0.tar.gz
RUN tar -zxvf nginx-1.22.0.tar.gz && cd nginx-1.22.0 && ./configure –prefix=/apps/nginx/ –with-http_ssl_module –user=nginx –group=nginx –with-http_gzip_static_module –with-http_stub_status_module –with-stream && make -j4 && make install
ADD init.sh /init.sh
CMD [“/bin/bash”,”init.sh”]
cat init.sh
/apps/nginx/sbin/nginx -g ‘daemon off;’
构建nginx
docker build -t nginx_manal:v2 .
启动服务
docker run -d -p 80:80 nginx_manal:v2
结果测试
