首先创建一个目录
mkdir /nginx
把nginx包上传
##dockerfile
vim Dockerfile
#install nginx
FROM centos
MAINTAINER yangchao
RUN groupadd -r nginx
RUN useradd -r -g nginx nginx
#install
RUN yum -y install gcc gcc-c++ openssl openssl-devel pcre-devel zlib-devel zlib
#copy
RUN mkdir -p /usr/local/nginx
ADD ./nginx-1.12.0.tar.gz /root
RUN cd /root/nginx-1.12.0 && ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
&& make && make install
#十分重要
RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
ADD ./docker-mario.tar.gz /usr/local/nginx/html
EXPOSE 80
ENTRYPOINT /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
创建镜像
docker build -t aaa .
docker images 查看新建的镜像
docker run -d -p 91:80 --name zzz aaa 创建容器
nginx源码包http://pan.baidu.com/s/1gftgEKr
超级玛丽包 http://pan.baidu.com/s/1hrZ1IXA