脚本内容
Dockerfile:
FROM cf2c3ece5e41
MAINTAINER from zichen
WORKDIR /usr/local/src
RUN yum install -y wget
RUN wget http://nginx.org/download/nginx-1.8.1.tar.gz
RUN tar -zxvf nginx-1.8.1.tar.gz
WORKDIR nginx-1.8.1
RUN yum -y install gcc-c++ make pcre-devel zlib-devel bind
RUN ./configure --prefix=/usr/local/nginx --with-pcre
RUN make
RUN make install
RUN /usr/local/nginx/sbin/nginx
RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
ADD run.sh /usr/local/sbin/run.sh
RUN chmod 755 /usr/local/sbin/run.sh
CMD ["/usr/local/sbin/run.sh"]
EXPOSE 22 80 433

run.sh#!/bin/bash
/usr/sbin/sshd &
/usr/local/nginx/sbin/nginx

2.创建镜像
docker build -t centos_nginx . 其中 . 代表dockerfile 所在的文件的路径