Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 4e0e542

Browse files
committed
builder: add note about alternative syntax
Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit a4a3d2f94dae8fe7db6ae9be6574087841a68fd9) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: f526bcdb535126c0a96a6c67413a90867b15b1ff Component: cli
1 parent fb91a7f commit 4e0e542

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

components/cli/docs/reference/builder.md

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,25 +1025,43 @@ The environment variables set using `ENV` will persist when a container is run
10251025
from the resulting image. You can view the values using `docker inspect`, and
10261026
change them using `docker run --env <key>=<value>`.
10271027
1028-
> **Note**
1029-
>
1030-
> Environment variable persistence can cause unexpected side effects. For example,
1031-
> setting `ENV DEBIAN_FRONTEND=noninteractive` changes the behavior of `apt-get`,
1032-
> and may confuse users of your image.
1028+
Environment variable persistence can cause unexpected side effects. For example,
1029+
setting `ENV DEBIAN_FRONTEND=noninteractive` changes the behavior of `apt-get`,
1030+
and may confuse users of your image.
1031+
1032+
If an environment variable is only needed during build, and not in the final
1033+
image, consider setting a value for a single command instead:
1034+
1035+
```dockerfile
1036+
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y ...
1037+
```
1038+
1039+
Or using [`ARG`](#arg), which is not persisted in the final image:
1040+
1041+
```dockerfile
1042+
ARG DEBIAN_FRONTEND=noninteractive
1043+
RUN apt-get update && apt-get install -y ...
1044+
```
1045+
1046+
> **Alternative syntax**
10331047
>
1034-
> If an environment variable is only needed during build, and not in the final
1035-
> image, consider setting a value for a single command instead:
1048+
> The `ENV` instruction also allows an alternative syntax `ENV <key> <value>`,
1049+
> omitting the `=`. For example:
10361050
>
10371051
> ```dockerfile
1038-
> RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y ...
1052+
> ENV MY_VAR my-value
10391053
> ```
10401054
>
1041-
> Or using [`ARG`](#arg), which is not persisted in the final image:
1055+
> This syntax does not allow for multiple environment-variables to be set in a
1056+
> single `ENV` instruction, and can be confusing. For example, the following
1057+
> sets a single environment variable (`ONE`) with value `"TWO= THREE=world"`:
10421058
>
10431059
> ```dockerfile
1044-
> ARG DEBIAN_FRONTEND=noninteractive
1045-
> RUN apt-get update && apt-get install -y ...
1060+
> ENV ONE TWO= THREE=world
10461061
> ```
1062+
>
1063+
> The alternative syntax is supported for backward compatibility, but discouraged
1064+
> for the reasons outlined above, and may be removed in a future release.
10471065
10481066
## ADD
10491067

0 commit comments

Comments
 (0)