Skip to content
章节导航

前端项目镜像制作: Nginx

shell
FROM centos:7
LABEL maintainer www.ctnrs.com

RUN yum install -y gcc gcc-c++ make \
  openssl-devel pcre-devel gd-devel\
  iproute net-tools telnet wget curl && \
  yum clean all &&\
  rm -rf /var/cache/yum/*

ADD nginx-1.15.5.targz /
RUN cd nginx-1.15.5 &&\
  ./configure --prefix=/usr/local/nginx\
  --with-http_ssl_module\
  --with-http_stub_status_module &&\
  make -j4 && make install &&
  mkdir /usr/local/nginx/conf/vhost &&\
  cd/&&rm -rfnginx*&&\
  In -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

ENV PATH $PATH:/usr/local/nginx/sbin

COPY nginx.conf /usr/local/nginx/conf/nginx.conf

WORKDIR /usr/local/nginx

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]

启动挂载前端页面

shell
docker run -d -v /opt/wwwroot:/usr/local/nginx/html --name web nginx:v1