centos 7.6 docker nginx

Centos7 docker nginx容器搭建

 

一、安装docker

https://www.cnblogs.com/alantop/p/12096153.html

二、创建Dockerfile

1
2
3
4
#创建文件夹
mkdir centos_nginx
cd centos_nginx
vim Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#指定使用那个基础镜像
FROM centos
MAINTAINER Dirk.Wang  510423039@qq.com
LABEL Discription="基于centos的nginx镜像" version="1.0"
WORKDIR /usr/local/src
RUN yum install -y wget
RUN wget http://nginx.org/download/nginx-1.8.0.tar.gz
RUN tar -zxvf nginx-1.8.0.tar.gz
WORKDIR nginx-1.8.0
#安装nginx所依赖的包
RUN yum -y install gcc-c++
RUN yum -y install pcre pcre-devel
RUN yum -y install zlib zlib-devel
RUN yum -y install openssl openssl-devel libssl-dev
RUN ./configure
RUN make
RUN make install
EXPOSE 80
1
docker build -t centos_nginx .

 

 

三、创建容器

1
docker run -dit -p 8085:80 centos_nginx

四、进去容器启动nginx

1
docker attach loving_haibt

  

  

五、开放端口

  

  

 

 

 

posted on 2019-12-25 13:29  alantop  阅读(512)  评论(0编辑  收藏  举报