无效定义描述

注意

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

输出

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 标志会打印构建目标和参数的描述。 这些描述是从 Dockerfile注释 生成的,这些注释紧接在FROMARG指令之前,并且以构建阶段或参数的名称开头。 例如:

# 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