5-Docker实例-nginx application

2023-12-20 09:38:51

1.编写Dockerfile文件,添加如下内容并保存

命令:

vim Dockerfile

[root@centos79 ~]# cat Dockerfile
FROM centos:centos7 

MAINTAINER ztj

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

ADD nginx-1.8.0.tar.gz /usr/local/
ADD epel-release-latest-7.noarch.rpm /usr/local/

RUN rpm -ivh /usr/local/epel-release-latest-7.noarch.rpm
RUN yum install -y vim net-tools wget lftp gcc gcc-c++ make openssl-devel pcre-devel pcre && yum clean all
RUN useradd -s /sbin/nologin -M www

WORKDIR /usr/local/nginx-1.8.0

RUN ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-pcre && make && make install
RUN echo "daemon off;" >>/etc/nginx.conf

EXPOSE 80

ENTRYPOINT ["nginx"]
CMD ["-g","daemon off;"]
[root@centos79 ~]# 

2.构建镜像及查看

命令:

docker build -t centos-nginx:1.0 -f /root/Dockerfile .

[root@centos79

文章来源:https://blog.csdn.net/z19861216/article/details/134547432
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。