2 DL3044
Petter Friberg edited this page 2024-04-03 15:28:47 +02:00

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.