阅读939 返回首页    go 阿里云 go 技术社区[云栖]


Docker 之 Dockerfile

Dockerfile 命令介绍

1、FROM 构建一个属于自己的镜像需要依赖一个基础镜像,就是指定一个官方提供的一个base image。在这个基础之上构建。例如使用daocloud.io提供的centos7作为基础镜像

FROM daocloud.io/centos:7

2、LABEL 一些注释信息,多行的话可以使用反斜线,以下三种方式

# Set one or more individual labels
LABEL com.example.version="0.0.1-beta"
LABEL vendor="ACME Incorporated"
LABEL com.example.release-date="2015-02-12"
LABEL com.example.version.is-production=""

# Set multiple labels on one line
LABEL com.example.version="0.0.1-beta" com.example.release-date="2015-02-12"

# Set multiple labels at once, using line-continuation characters to break long lines
LABEL vendor=ACME\ Incorporated \
      com.example.is-beta= \
      com.example.is-production="" \
      com.example.version="0.0.1-beta" \
      com.example.release-date="2015-02-12"

3、RUN
RUN 后面要加上要构建镜像时,所要执行的脚本,多行命令换行也可以使用反斜线 \ 来分隔,例如在centos7上安装并启用httpd

RUN yum -y install httpd \
      systemctl enable httpd.service

最后更新:2017-05-25 10:01:19

  上一篇:go  《计算机存储与外设》----1.3 Cache的组织
  下一篇:go  Machine Learning-based Web Exception Detection