moby / moby/buildkit

BuildKit should warn about unconsumed build-args

Open
#2,128 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/feature-parity area/ux kind/enhancement
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

relates to https://github.com/docker/cli/issues/441#issuecomment-841391407

The classic builder printed a warning if a build-arg was passed, but not used in the Dockerfile. BuildKit does not have an equivalent for this

Without BuildKit:

DOCKER_BUILDKIT=0 docker build --build-arg FOO=bar -<<EOF
FROM busybox
RUN echo hello
EOF

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM busybox
 ---> 388056c9a683
Step 2/2 : RUN echo hello
 ---> Running in 0ff64e1edd4b
hello
Removing intermediate container 0ff64e1edd4b
 ---> 26859e806085
[Warning] One or more build-args [FOO] were not consumed
Successfully built 26859e806085

With BuildKit:

DOCKER_BUILDKIT=1 docker build --build-arg FOO=bar -<<EOF
FROM busybox
RUN echo hello
EOF

[+] Building 0.5s (6/6) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                   0.1s
 => => transferring dockerfile: 70B                                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/busybox:latest                                                                                                                                      0.0s
 => CACHED [1/2] FROM docker.io/library/busybox                                                                                                                                                        0.0s
 => [2/2] RUN echo hello                                                                                                                                                                               0.3s
 => exporting to image                                                                                                                                                                                 0.0s
 => => exporting layers                                                                                                                                                                                0.0s
 => => writing image sha256:af09f7baeb292afd37bf948398584d8d8299ede11aae4bf0654f038e082001fa

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how BuildKit processes build arguments during a Dockerfile build, using the issue's classic-builder and BuildKit examples as the behavioral reference. Done means an unused argument produces an equivalent warning during a BuildKit build, while a consumed argument does not.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.