New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerfile: required ARG not validated in global space #4847
Comments
I think this is still the only thing that can be considered issue. I'm not 100% what case we wanted to avoid by not handling error there, other than avoiding ARG used by other target failing the build. I'm in favor of adding the error handling back, but note that this make all the examples fail.
Indeed, there is no such optimization to not evaluate base image names when determining dependencies between stages.
These all look the same. There is no The current behavior is:
|
After discussing with @tonistiigi on Slack, I'm opening this as a separate ticket; this was originally posted as a solution for / part of the ticket below;
Starting with this Dockerfile;
Stage one (attempt one)
Trying to build stage one, produces an error because stage five is also evaluated (although it's not immediately clear why; possibly it constructs a list of all sources (
AS five
could be used as part of another stage), but for that it may not have to evaluate theFROM
part);Stage one
Building stage
one
does not produce an error; all of the global args are ignored.Building stage two
Building stage
two
produces an error at the location of the override (which also marks the arg as required); this could be considered the expected behavior; it looks to optimize, and not pull theubuntu:18.04
image (which is good);Building stage three
Building stage
three
completes successfully; this looks unexpected, as the stage explicitly definesREQUIRED_ARG3
. Also note that the argument is set as an environment variable, but as an empty value (REQUIRED_ARG3=
). Given that the arg is defined without=
in the stage, it should probably not be set (but maybe it's set because of the global arg, and validation is skipped there).If all validation worked, I also would expect it to optimize execution, and to not pull the image.
Building stage four
Stage four also builds successfully, but because it evaluates
REQUIRED_ARG4
to an empty string, it does not produce an error for the build-arg not being set;Reproduced on docker desktop with docker engine 26.0.0 with the containerd image-store enabled;
Client: Cloud integration: v1.0.35+desktop.13 Version: 26.0.0 API version: 1.45 Go version: go1.21.8 Git commit: 2ae903e Built: Wed Mar 20 15:14:46 2024 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.30.0 (145546) Engine: Version: 26.0.0 API version: 1.45 (minimum version 1.24) Go version: go1.21.8 Git commit: 8b79278 Built: Wed Mar 20 15:18:02 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.6.28 GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb runc: Version: 1.1.12 GitCommit: v1.1.12-0-g51d5e94 docker-init: Version: 0.19.0 GitCommit: de40ad0
The text was updated successfully, but these errors were encountered: