閱讀939 返回首頁    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