Debian Codegraph @

buildkit/frontend/dockerfile/linter/docs/LegacyKeyValueFormat.md

raw
1 ## Output
2
3 ```text
4 "ENV key=value" should be used instead of legacy "ENV key value" format
5 ```
6
7 ## Description
8
9 The correct format for declaring environment variables and build arguments in a
10 Dockerfile is `ENV key=value` and `ARG key=value`, where the variable name
11 (`key`) and value (`value`) are separated by an equals sign (`=`).
12 Historically, Dockerfiles have also supported a space separator between the key
13 and the value (for example, `ARG key value`). This legacy format is deprecated,
14 and you should only use the format with the equals sign.
15
16 ## Examples
17
18 ❌ Bad: using a space separator for variable key and value.
19
20 ```dockerfile
21 FROM alpine
22 ARG foo bar
23 ```
24
25 ✅ Good: use an equals sign to separate key and value.
26
27 ```dockerfile
28 FROM alpine
29 ARG foo=bar
30 ```
31
32 ❌ Bad: multi-line variable declaration with a space separator.
33
34 ```dockerfile
35 ENV DEPS \
36 curl \
37 git \
38 make
39 ```
40
41 ✅ Good: use an equals sign and wrap the value in quotes.
42
43 ```dockerfile
44 ENV DEPS="\
45 curl \
46 git \
47 make"
48 ```