-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Improve docs about ARG in FROM #333
Conversation
Codecov Report
@@ Coverage Diff @@
## master #333 +/- ##
=======================================
Coverage 48.85% 48.85%
=======================================
Files 186 186
Lines 12413 12413
=======================================
Hits 6064 6064
Misses 5975 5975
Partials 374 374 |
@@ -530,8 +530,10 @@ FROM extras:${CODE_VERSION} | |||
CMD /code/run-extras | |||
``` | |||
|
|||
To use the default value of an `ARG` declared before the first `FROM` use an | |||
`ARG` instruction without a value: | |||
An `ARG` declared before a `FROM` is outside of a build stage, so it |
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.
Maybe better to mention that every stage has individual args, then it is better to understand that "arg-in-from" is not an exception but just follows the rule.
How about this example:
ARG VERSION=latest
FROM busybox:$VERSION
ARG VERSION
RUN echo $VERSION > image_version
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.
Maybe something like "An ARG
instructions is only relevant for the next FROM
instruction that comes after it in the Dockerfile, and then using this example to illustrate that.
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.
Maybe something like "An ARG instructions is only relevant for the next FROM instruction that comes after it in the Dockerfile,
That's not exactly correct. There are two cases:
- any
ARG
before the firstFROM
can be used in anyFROM
line - any
ARG
within a build stage (after aFROM
) can be used in that build stage
I can add more details to the ARG
reference section as well (this stuff is under FROM
) , but I think this line needs to be updated as well something along the lines of what I have.
@@ -530,8 +530,10 @@ FROM extras:${CODE_VERSION} | |||
CMD /code/run-extras | |||
``` | |||
|
|||
To use the default value of an `ARG` declared before the first `FROM` use an | |||
`ARG` instruction without a value: | |||
An `ARG` declared before a `FROM` is outside of a build stage, so it |
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.
Maybe something like "An ARG
instructions is only relevant for the next FROM
instruction that comes after it in the Dockerfile, and then using this example to illustrate that.
I've updated to include more details, and added some more structure to the |
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.
The text lgtm but the examples could be better. The image_version
example was specifically for the case where it may make sense to use the same variable in FROM
and inside the stage. I would switch the examples and make "arg-in-from" use the image_version
and arguments in multiple stages use ARG SETTINGS
.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
e162210
to
ad5d035
Compare
Makes sense, I've swapped the examples. |
LGTM |
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.
LGTM, thanks!
See docker/for-linux#59 and moby/moby#31352 (comment) and moby/moby#34008