Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
docs(docker): lABEL指令学习
Browse files Browse the repository at this point in the history
  • Loading branch information
zjZSTU committed Sep 23, 2019
1 parent c085517 commit 0dfc7ec
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/source/docker/dockerfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Dockerfile指令

dockerfile/FROM
dockerfile/CMD
dockerfile/RUN
dockerfile/RUN
dockerfile/LABEL
37 changes: 37 additions & 0 deletions docs/source/docker/dockerfile/LABEL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# LABEL

参考:[LABEL](https://docs.docker.com/engine/reference/builder/#label)

`LABEL`指令为镜像添加元数据

## 语法

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

使用键值对形式,单个`LABEL`指令可以添加一个或多个键值对,一个`Dockerfile`文件中可以包含多个`LABEL`指令

**如果键值对存在空格或者过长,可以使用双引号和反斜杠**

```
LABEL "com.example.vendor"="ACME Incorporated"
LABEL com.example.label-with-value="foo"
LABEL multi.label1="value1" multi.label2="value2" other="value3"
LABEL multi.label1="value1" \
multi.label2="value2" \
other="value3"
```

## 继承

新的镜像可以继承来自基镜像或者父镜像的`LABEL`信息,如果设置了同名键值对,则会覆盖之前的信息

## 查询

使用命令`docker inspect`进行查询

```
$ docker inspect IMAGE | grep -i LABEL
```

0 comments on commit 0dfc7ec

Please sign in to comment.