Browse code

Improve build cache miss doc for `ARG` and `RUN`

The documentation already says the cache miss happens only at `ARG`
variable usage, not declaration, but there is a very common implicit
usage: `RUN`, which this commit documents even more, improving on #21790.

Also, use `definition` instead of `declaration`: it's the same thing, and
`definition` is already used in this documentation, contrary to
`declaration`.

Also, distinguish between "instructions" and "variables defined by `ARG`
instructions".

Signed-off-by: Thomas Riccardi <riccardi@systran.fr>

Thomas Riccardi authored on 2016/04/08 18:23:48
Showing 1 changed files
... ...
@@ -1174,8 +1174,9 @@ To use these, simply pass them on the command line using the `--build-arg
1174 1174
 `ARG` variables are not persisted into the built image as `ENV` variables are.
1175 1175
 However, `ARG` variables do impact the build cache in similar ways. If a
1176 1176
 Dockerfile defines an `ARG` variable whose value is different from a previous
1177
-build, then a "cache miss" occurs upon first use of the `ARG` variable. The
1178
-declaration of the `ARG` variable does not count as a use.
1177
+build, then a "cache miss" occurs upon its first usage, not its definition. In
1178
+particular, all `RUN` instructions following an `ARG` instruction use the `ARG`
1179
+variable implicitly (as an environment variable), thus can cause a cache miss.
1179 1180
 
1180 1181
 For example, consider these two Dockerfile:
1181 1182