InvalidDefinitionDescription

注意

此检查是实验性的,默认情况下未启用。要启用它,请参阅 实验性检查

输出

Comment for build stage or argument should follow the format: `# <arg/stage name> <description>`. If this is not intended to be a description comment, add an empty line or comment between the instruction and the comment.

描述

docker build 命令的 --call=outline--call=targets 标志打印构建目标和参数的描述。这些描述从紧接在 FROMARG 指令之前,并以构建阶段或参数名称开头的 Dockerfile 注释中生成。例如

# build-cli builds the CLI binary
FROM alpine AS build-cli
# VERSION controls the version of the program
ARG VERSION=1

如果前面的注释并非用于描述,请在指令和前面的注释之间添加一个空行或注释。

示例

❌ 差:在 FROM 命令前面一行放置非描述性注释。

# a non-descriptive comment
FROM scratch AS base

# another non-descriptive comment
ARG VERSION=1

✅ 好:用空行分隔非描述性注释。

# a non-descriptive comment

FROM scratch AS base

# another non-descriptive comment

ARG VERSION=1

✅ 好:紧接在命令后面描述 ARG 键和阶段的注释。

# base is a stage for compiling source
FROM scratch AS base
# VERSION This is the version number.
ARG VERSION=1
页面选项