标签:docker
Dockerfile
FROM 基础镜像
MAINTAINER 维护这信息
RUN 运行什么命令,在命令前面加上RUN
ADD 往里面加点文件,copy文件,会自动解压
WORKDIR 当前的工作目录
VOLUME 目录挂载
EXPOSE 开放的端口
RUN 进程要一直运行
实战:构建nginx
wget http://nginx.org/download/nginx-1.9.3.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
#This is My first Dockerfile#version 1.0#Author: hh #Base image 基础镜像 FROM centos #MAINTAINER 维护者信息 MAINTAINER hh Wang #ADD ADD pcre-8.38.tar.gz /usr/local/srcADD nginx-1.9.3.tar.gz /usr/local/src #RUN RUN yum -y install wget gcc gcc-c++ make openssl openssl-devel RUN useradd -s /sbin/nologin -M www #WORKDIR WORKDIR /usr/local/src/nginx-1.9.3 RUN ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module \--with-pcre=/usr/local/src/pcre-8.38 && make && make install RUN echo "daemon off;">>/usr/local/nginx/conf/nginx.conf #ENV定义环境变量 ENV PATH /usr/local/nginx/sbin:$PATH #EXPOSE 映射端口 EXPOSE 80 CMD ["nginx"]
docker build -t whh/nginx-file:v1 .
docker run -d -it -p 93:80 --name nginx whh/nginx-file:v1
标签:docker
原文地址:http://xiaotaozi.blog.51cto.com/9339563/1868036