Browse code

docs: explain when RUN cache gets invalidated

This adds a few lines to the RUN Dockerfile docs to explain how to
bypass the RUN caching and how ADD can also invalidate the cache for
these instructions.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)

unclejack authored on 2014/05/15 17:56:23
Showing 1 changed files
... ...
@@ -131,6 +131,16 @@ any point in an image's history, much like source control.
131 131
 The *exec* form makes it possible to avoid shell string munging, and to `RUN`
132 132
 commands using a base image that does not contain `/bin/sh`.
133 133
 
134
+The cache for `RUN` instructions isn't invalidated automatically during the
135
+next build. The cache for an instruction like `RUN apt-get dist-upgrade -y`
136
+will be reused during the next build.
137
+The cache for `RUN` instructions can be invalidated by using the `--no-cache`
138
+flag, for example `docker build --no-cache`.
139
+
140
+The first encountered `ADD` instruction will invalidate the cache for all
141
+following instructions from the 'Dockerfile' if the contents of the context
142
+have changed. This will also invalidate the cache for `RUN` instructions.
143
+
134 144
 ### Known Issues (RUN)
135 145
 
136 146
 - [Issue 783](https://github.com/dotcloud/docker/issues/783) is about file