無效的定義描述

注意

此檢查為實驗性功能,預設為停用。如需啟用,請參閱實驗性檢查

輸出

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