Skip to content

Commit d346545

Browse files
authored
Merge pull request #21143 from dvdksn/bake-escape-var-interpolation
build(bake): escape variable interpolation in bake definition
2 parents b0c0082 + a11c11f commit d346545

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

content/manuals/build/bake/variables.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,35 @@ $ docker buildx bake --print
7878
}
7979
```
8080

81+
## Escape variable interpolation
82+
83+
If you want to bypass variable interpolation when parsing the Bake definition,
84+
use double dollar signs (`$${VARIABLE}`).
85+
86+
```hcl
87+
target "default" {
88+
dockerfile-inline = <<EOF
89+
FROM alpine
90+
ARG TARGETARCH
91+
RUN echo "Building for $${TARGETARCH/amd64/x64}"
92+
EOF
93+
platforms = ["linux/amd64", "linux/arm64"]
94+
}
95+
```
96+
97+
```console
98+
$ docker buildx bake --progress=plain
99+
...
100+
#8 [linux/arm64 2/2] RUN echo "Building for arm64"
101+
#8 0.036 Building for arm64
102+
#8 DONE 0.0s
103+
104+
#9 [linux/amd64 2/2] RUN echo "Building for x64"
105+
#9 0.046 Building for x64
106+
#9 DONE 0.1s
107+
...
108+
```
109+
81110
## Using variables in variables across files
82111

83112
When multiple files are specified, one file can use variables defined in

0 commit comments

Comments
 (0)