Dokcer学习笔记之Dokcerfile 文件构建
vim Dockerfile#First dockerfile FROM centos
MAINTAINER chen
RUN yum -y install wget
RUN wget -S https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN rpm -ivh epel-release-latest-7.noarch.rpm
RUN yum -y install nginx
EXPOSE 80
用dockerfile文件建立镜像
docker build -t web-nginx-1.7 .
FROM <image>
FROM <image><tag>
MAINTAINER 指定镜像的作者信息和联系信息
RUN 指定当前镜像运行命令包含两种指令模式(此指令是在容器构建时候运行的)
1、 RUN <command> (shell 模式)
/bin/sh -c command
RUN echo hello
2、RUN["executable","param1","param2"] (exec模式)
RUN["/bin/bash","-c","echo hello"]
CMD 指令在容器运行时运行的,在指定docker run 时指定了运行命令则此命令不会在执行
CMD["executable","param1","param2"](exec模式)
CMD["/usr/bin/nginx","-g","daemon off;"]
CMD command param1 param2(shell 模式)
ADD<src>..<dest>
COPY<src>..<dest>
ADD 包含类似tar的解压缩命令,如果单纯的复制,Docker推荐使用COPY
ENV <key><value>
USER daemon基于什么用户运行
docker build --no-cache不建立缓存
或者 ENV REFRESH_DATE 2015-07-06
docker history images 查看镜像构建过程
页:
[1]