Dockerfile(2) - LABEL 指令详解

LABEL

可以为生成的镜像添加元数据标签信息,这些信息可以用来辅助过滤出特定镜像

LABEL <key>=<value> <key>=<value> <key>=<value> ...

 

栗子一

# key 加了 "
LABEL "com.example.vendor"="ACME Incorporated"

# key 没有 "
LABEL com.example.label-with-value="foo"
LABEL version="1.0"

# 换行
LABEL description="This text illustrates \
that label-values can span multiple lines."

  

栗子二

一行添加多个 key=value

LABEL multi.label1="value1" multi.label2="value2" other="value3"

等价写法

LABEL multi.label1="value1" \
      multi.label2="value2" \
      other="value3"

 

通过 docker inspect 查看添加的元数据

> docker image inspect --format='' myimage
{
  "com.example.vendor": "ACME Incorporated",
  "com.example.label-with-value": "foo",
  "version": "1.0",
  "description": "This text illustrates that label-values can span multiple lines.",
  "multi.label1": "value1",
  "multi.label2": "value2",
  "other": "value3"
}

 

 
posted @ 2021-10-31 13:31  小菠萝测试笔记  阅读(623)  评论(0编辑  收藏  举报