-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
docker build -no-cache
does not consistently invalidate the cache for subsequent builds
#3199
Comments
@vreon |
@crosbymichael That's fine, but it clearly does invalidate the cache for some builds (see my first example, which should have produced |
@vreon 1st buid produce |
@vieux That makes sense... but then, why didn't my second example use Sorry, I promise I'm not trying to be obnoxious! :) |
@vreon I see |
@vieux But that's true for both examples. They both look like this:
The only difference between the two examples is part of the RUN. Why do they do different things? |
Doesn't this raise the fact that if @vreon is correct, that you risk having inconsistent cache results in builds? The only way, then, is to always use -no-cache to ensure you NEVER use a cache at all. When, in fact, I would like to have a command that invalidates a cache entry for a specific RUN command per Dockerfile/image build at the very least. Can we at least have a mechanism to list how many entries from a Dockerfile/build are in the cache, and allow for invalidating those entries? |
@borromeotlhs please see prior discussions on influencing the cache in |
By the way, it's
(with two leading hyphens) |
@samistart, Docker used single dashes for long options in 2013. I haven't used |
In this example,
docker build -no-cache
appears to invalidate the cache for subsequent builds:"Awesome," you'd think, "
-no-cache
is a nice way to force a full rebuild and account for the occasional RUN that isn't actually deterministic."But then you try it with a slightly different RUN instruction:
So now
-no-cache
appears to not invalidate the cache -- the third build used the images generated by the first. Essentially, the first time you use-no-cache
, you have to keep using-no-cache
on all subsequent builds, or you risk reusing a layer you thought invalidated.The text was updated successfully, but these errors were encountered: