Skip to main content

PG004: Use ENV key=value format instead of legacy ENV key value

Info Maintainability

Why This Matters

The legacy `ENV KEY value` syntax (space-separated) only supports one variable per instruction and can be ambiguous when the value contains spaces. Docker recommends the `ENV KEY=value` syntax, which is explicit, supports multiple variables per line, and avoids parsing surprises. The legacy format can cause subtle bugs when values have leading or trailing spaces.

How to Fix

Use the key=value syntax for ENV instructions

Before (incorrect)

ENV MY_VAR some value

After (correct)

ENV MY_VAR="some value"

Rule Details

Rule Code
PG004
Severity
Info
Category
Maintainability

Related Rules