mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-26 19:55:23 +00:00
Remove blank lines after code block markers
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
```docker
|
||||
LABEL <key>=<value> <key>=<value> ...
|
||||
```
|
||||
|
||||
`LABEL` 指令以键值对的形式给镜像添加元数据。这些数据不会影响镜像的功能,但可以帮助用户理解镜像,或被自动化工具使用。
|
||||
|
||||
---
|
||||
@@ -27,7 +26,6 @@ LABEL <key>=<value> <key>=<value> ...
|
||||
LABEL version="1.0"
|
||||
LABEL description="这是一个 Web 应用服务器"
|
||||
```
|
||||
|
||||
#### 定义多个标签:推荐
|
||||
|
||||
```docker
|
||||
@@ -36,7 +34,6 @@ LABEL maintainer="user@example.com" \
|
||||
description="My App Description" \
|
||||
org.opencontainers.image.authors="Yeasy"
|
||||
```
|
||||
|
||||
> 💡 包含空格的值需要用引号括起来。
|
||||
|
||||
---
|
||||
@@ -65,7 +62,6 @@ LABEL org.opencontainers.image.authors="yeasy" \
|
||||
org.opencontainers.image.source="https://github.com/yeasy/docker_practice" \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 7.14.5 MAINTAINER 指令:已废弃
|
||||
@@ -73,16 +69,13 @@ LABEL org.opencontainers.image.authors="yeasy" \
|
||||
旧版本的 Dockerfile 中常看到 `MAINTAINER` 指令:
|
||||
|
||||
```docker
|
||||
|
||||
## ❌ 已弃用
|
||||
|
||||
MAINTAINER user@example.com
|
||||
```
|
||||
|
||||
现在推荐使用 `LABEL`:
|
||||
|
||||
```docker
|
||||
|
||||
## ✅ 推荐
|
||||
|
||||
LABEL maintainer="user@example.com"
|
||||
@@ -91,7 +84,6 @@ LABEL maintainer="user@example.com"
|
||||
|
||||
LABEL org.opencontainers.image.authors="user@example.com"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 7.14.6 动态标签
|
||||
@@ -105,7 +97,6 @@ ARG VCS_REF
|
||||
LABEL org.opencontainers.image.created=$BUILD_DATE \
|
||||
org.opencontainers.image.revision=$VCS_REF
|
||||
```
|
||||
|
||||
构建命令:
|
||||
|
||||
```bash
|
||||
@@ -114,7 +105,6 @@ $ docker build \
|
||||
--build-arg VCS_REF=$(git rev-parse --short HEAD) \
|
||||
.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 7.14.7 查看标签
|
||||
@@ -129,13 +119,11 @@ $ docker inspect nginx --format '{{json .Config.Labels}}' | jq
|
||||
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
|
||||
}
|
||||
```
|
||||
|
||||
#### 过滤器
|
||||
|
||||
可以使用标签过滤镜像:
|
||||
|
||||
```bash
|
||||
|
||||
## 列出作者是 yeasy 的所有镜像
|
||||
|
||||
$ docker images --filter "label=org.opencontainers.image.authors=yeasy"
|
||||
@@ -144,5 +132,4 @@ $ docker images --filter "label=org.opencontainers.image.authors=yeasy"
|
||||
|
||||
$ docker rmi $(docker images -q --filter "label=stage=builder")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user