ENV documentation suggests misleading alternative #19902
Labels
area/build
Relates to Dockerfiles or docker build command
lifecycle/frozen
status/triage
Needs triage
Is this a docs issue?
Type of issue
Information is incorrect
Description
In the documentation for the
ENV
instruction, there is an example that reads:I think that suggestion is misleading, as IIUC
DEBIAN_FRONTEND
is only defined for the first commandapt-get update
and not for theapt-get install
step. It is therefore not equivalent to the examples that useENV
orARG
.Example demonstrating the problem:
In the above example,
FOO
is defined only in the first call toprintenv
.Location
https://docs.docker.com/reference/dockerfile/
Suggestion
Perhaps the most obvious solution is to repeat
DEBIAN_FRONTEND
:For this particular use case in which the environment variable needs to be available to multiple commands but not be persistent in the final image, I'd emphasize the use of
ARG
instead, as it is less error-prone.The text was updated successfully, but these errors were encountered: