系统相关
首页 > 系统相关> > docker源码安装nginx容器

docker源码安装nginx容器

作者:互联网

nginx源码下载地址

下载包

[root@node0 ~]# wget http://nginx.org/download/nginx-1.14.2.tar.gz

创建安装目录

[root@node0 ~]# tree nginx-install/
nginx-install/
├── Dockerfile
└── nginx-1.14.2.tar.gz

编辑Dockerfile文件

[root@node0 ~]# vim nginx-install/Dockerfile 

FROM centos:latest
LABEL MAINTAINER "FXX Fxx@123.com"
ADD ./nginx-1.14.2.tar.gz /usr/local/src
ENV PATH /usr/local/nginx/sbin:$PATH
RUN yum -y install bzip2 make openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ libxml2-devel
RUN useradd -s /sbin/nologin nginx
WORKDIR /usr/local/src/nginx-1.14.2
RUN /bin/bash  ./configure --prefix=/usr/local/nginx --user=nginx  --group=nginx
RUN make && make install
RUN ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
EXPOSE 80
CMD ["/usr/sbin/nginx", "-g" ,"daemon off;"]

创建nginx镜像

docker build -t nginx/web:v1.2 nginx-install/

运行容器

[root@node0 ~]# docker run -itd -p 80:80 --name web nginx/web:v1.2

进入查看端口

[root@node0 ~]# docker exec -it web /bin/bash
[root@6c7909e28e3b nginx-1.14.2]# ss -antl
State              Recv-Q             Send-Q                          Local Address:Port                           Peer Address:Port             
LISTEN             0                  128                                   0.0.0.0:80                                  0.0.0.0:*        

标签:1.14,nginx,源码,usr,install,node0,docker,root
来源: https://www.cnblogs.com/fangxinxin/p/14483688.html