Skip to content
Petter Friberg edited this page Apr 3, 2024 · 2 revisions

Do not refer to an environment variable within the same ENV statement where it is defined.

Problematic code:

ENV FOO=bar \
    BAZ=${FOO}/bla

Correct code:

ENV FOO=bar
ENV BAZ=${FOO}/bla

Rationale:

Docker will not expand a variable within the same ENV statement where it is defined. While it will not crash Docker, it carries a high likelihood of errors.