What are the differences between the --cache-from flag in docker build and the RUN --mount type=cache in the Dockerfile itself? Are BOTH needed to leverage cache?
Do I need to have pulled the image before or will it be pulled automatically if I don't have it yet? Does this also work with buildx? I think that normally doesn't look at local images as it has its own cache?
@@anthonywritescode thanks, I don't think the documentation makes this clear. I assumed it looked at the remote since I'm providing a registry url. This could explain some unreliable behavior I've seen in the past with inexplicable cache misses
What are the differences between the --cache-from flag in docker build and the RUN --mount type=cache in the Dockerfile itself? Are BOTH needed to leverage cache?
Thanks for the wonderful explanation Anthony. Wish this feature worked with the multistage Dockerfile builds as well.
you can! you just need to tag and push all the intermediate images
Do I need to have pulled the image before or will it be pulled automatically if I don't have it yet? Does this also work with buildx? I think that normally doesn't look at local images as it has its own cache?
you do need to pull yes -- seems to work with buildx as well
@@anthonywritescode thanks, I don't think the documentation makes this clear. I assumed it looked at the remote since I'm providing a registry url. This could explain some unreliable behavior I've seen in the past with inexplicable cache misses
yeah the docs for this are abysmal -- they used to be better but I presume the useful context was lost when adding the BUILDKIT stuff