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