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
(maint) Scoping for Docker ARGs is not intuitive #2275
Conversation
See also moby/moby#37345 |
For multi-stage builds, setting `ARG`s before the `FROM` makes their scope global, but you still need to have an `ARG foo` line in each build step to use the global `ARG foo`. For single-stage builds, it doesn't make sense to define `ARG`s before the `FROM` except for `ARG`s used in the `FROM`, since global scope doesn't really help with only one stage.
1aaa976
to
aab508b
Compare
ARG version="6.0.0" | ||
ARG namespace="puppet" | ||
FROM "$namespace"/puppetserver-base:"$version" | ||
ARG vcs_ref |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's only one stage in this file, why not also move the version
and namespace
values below the FROM
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because those are used in the FROM
line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahahaha, I suppose that's a good reason! Sheesh.
aab508b
to
5e6b61a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ship it
For multi-stage builds, setting
ARG
s before theFROM
makes theirscope global, but you still need to have an
ARG foo
line in each buildstep to use the global
ARG foo
.For single-stage builds, it doesn't make sense to define
ARG
s beforethe
FROM
except forARG
s used in theFROM
, since global scopedoesn't really help with only one stage.