Share feedback
Answers are generated based on the documentation.

LegacyKeyValueFormat

出力

"ENV key=value" should be used instead of legacy "ENV key value" format

(訳: 旧表記 "ENV key value" ではなく "ENV key=value" を用いるべきです)

内容説明

Dockerfile における環境変数やビルド引数を宣言する場合は、ENV key=valueARG key=value とするのが正しい書式です。 つまり変数名 (key) と値 (value) は等号 (=) によって区切ります。 これまで Dockerfile では、キーと値の区切り文字として空白もサポートしてきました (たとえば ARG key value)。 この書式は古いものとして廃止予定になっています。 等号を用いた書式のみを用いるようにしてください。

❌ 不可: 変数キーと値の間に空白区切りを用いています。

FROM alpine
ARG foo bar

✅ 可: キーと値の区切りに等号を用いています。

FROM alpine
ARG foo=bar

❌ 不可: 複数行で構成される宣言にて空白区切りが用いられています。

ENV DEPS \
    curl \
    git \
    make

✅ 可: 値をクォーテーション内にラップして等号を用いています。

ENV DEPS="\
    curl \
    git \
    make"
メモ

Be aware of leading whitespace when converting multi-line legacy syntax to the modern key=value format. In the legacy format, leading whitespace on continuation lines is included in the value. In the modern format with quoted values, leading whitespace inside the quotes is also preserved. If you don't want leading whitespace in the value, make sure to remove it when rewriting to the new format:

ENV DEPS="\
curl \
git \
make"