In my Dockerfile I use curl or ADD to download the latest version of an archive like:
FROM debian:jessie
...
RUN apt-g
docker build --no-cache would invalidate the cache for all the commands.
Dockerfile ADD command used to have the cache invalidated. Although it has been improved in recent docker version:
Docker is supposed to checksum any file added through ADDand then decide if it should use the cache or not.
So if the file added has changed, the cache should be invalidated for the ADD command.
Issue 1326 mentions other tips:
This worked.
RUN yum -y install firefox #redo
So it looks like Docker will re-run the step (and all the steps below it) if the string I am passing to
RUNcommand changes in anyway - even it's just a comment.The docker cache is used only, and only if none of his ancestor has changed (this behavior makes sense, as the next command will add change to the previous layer).
The cache is used if there isn't any character which has changed (so even a space is enough to invalidate a cache).