Debian Codegraph @

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

raw
1 ## Output
2
3 ```text
4 FROM argument 'VARIANT' is not declared
5 ```
6
7 ## Description
8
9 This rule warns for cases where you're consuming an undefined build argument in
10 `FROM` instructions.
11
12 Interpolating build arguments in `FROM` instructions can be a good way to add
13 flexibility to your build, and lets you pass arguments that overriding the base
14 image of a stage. For example, you might use a build argument to specify the
15 image tag:
16
17 ```dockerfile
18 ARG ALPINE_VERSION=3.20
19
20 FROM alpine:${ALPINE_VERSION}
21 ```
22
23 This makes it possible to run the build with a different `alpine` version by
24 specifying a build argument:
25
26 ```console
27 $ docker buildx build --build-arg ALPINE_VERSION=edge .
28 ```
29
30 This check also tries to detect and warn when a `FROM` instruction reference
31 miss-spelled built-in build arguments, like `BUILDPLATFORM`.
32
33 ## Examples
34
35 ❌ Bad: the `VARIANT` build argument is undefined.
36
37 ```dockerfile
38 FROM node:22${VARIANT} AS jsbuilder
39 ```
40
41 ✅ Good: the `VARIANT` build argument is defined.
42
43 ```dockerfile
44 ARG VARIANT="-alpine3.20"
45 FROM node:22${VARIANT} AS jsbuilder
46 ```