-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ARG/ENV used in script does not invalidate build cache #1688
Comments
After some code investigation, I know that kaniko compute cache layer CompositeKey by command(RUN/COPY), ARG, ENV. That means it not use script which has ARG called by command. So it can invalidate cache by this way:
The point is by using I do not know if there is some better way to solve this issue cuz this code is hard to understand by who has no context, pls let me know if you have better idea. |
Same issue. I'm looking forward to this fix. |
This issue is introduce by #1008 #1085 I added my comments over the old PR but ill reiterate here. the current behavior is introduced in that PR as a fix to people complaining ARG causing excessive cache invalidation. But according do dockerfile standard https://docs.docker.com/engine/reference/builder/#impact-on-build-caching
In the old fix, only explicit ARG usage are treated as cache miss where in the docker standard all RUN statement should in fact trigger cache miss because any scripts in RUN could use ARG without explicit reference. |
Maybe we can provide an option to indicate whether ARG exempt from caching. |
Actual behavior
ARG/ENV used in script does not invalidate build cache, e.g.
Dockerfile
:test.sh
when use kaniko to build image by given different ARGs, it will use cache layer.
Expected behavior
when use docker to build image by given different ARGs, it will NOT use cache layer. e.g.
Output
To Reproduce
Steps to reproduce the behavior:
Dockerfile
:test.sh
RUN cat /test.sh
NOT to use cache layer (build log can not seeFound cached layer, extracting to filesystem
)Additional Information
Triage Notes for the Maintainers
--cache
flagThe text was updated successfully, but these errors were encountered: