3 ms·
I think using RUN wget/curl is actually cached better than ADD [URL], which will invalidate your build steps cache more often unless I'm mistaken.
by alpb 7y ago
I think using RUN wget/curl is actually cached better than ADD [URL], which will invalidate your build steps cache more often unless I'm mistaken.
- orf 7y agoIt's also easier to clean up, i.e download a file, do something with it and then remove it. With ADD this is impossible.
- rcfox 7y agoDoesn't ADD do the download unconditionally but only invalidate the cache if the contents change? The only good use for ADD that I've found is for invalidating git clones from GitHub: ADD https://api.github.com/repos/<user>/<repo>/git/refs/heads/<branch> version.json RUN git clone --depth=1 --single-branch --branch=<branch> https://github.com/<user>/<repo>.git
- PhilippGille 7y agoIf I remember correctly it's like this: RUN cache is invalidated when the text (the whole RUN line) itself changes, which can be bad if you update a remote zip archive that you download with `RUN curl ...` and then expect the image to be updated after a simple `docker build`. This also goes for `RUN apk add ...` where the package might have received critical security updates but you're not getting them into your image because the cache is used. COPY and ADD caches are invalidated when the hash of the actual file content that's added changes, which is usually what you want.