一、安装docker
二、创建Dockerfile
#创建文件夹
mkdir centos_nginx
cd centos_nginx
vim Dockerfile
#指定使用那个基础镜像
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
docker build -t centos_nginx .
三、创建容器
docker run -dit -p 8085:80 centos_nginx
四、进去容器启动nginx
docker attach loving_haibt
五、开放端口