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
No way to use both --cache-from and a local store? #32612
Comments
ping @tonistiigi |
|
For context, my use case is docker-compose for a stack that runs both locally (for developers) and on travis (for tests). Travis doesn't maintain a docker cache across runs, so --cache-from is a godsend. But locally we'd really like to use our local caches since most of the time the entire image is cached, rather than just some reasonably recent one (and one we haven't necessarily pulled) But we'd ideally like to use the same docker-compose.yml for both local and travis runs. Which means our docker-compose.yml looks like (paraphrased):
Which works as well as possible on Travis, but locally means we lose how great our local cache should run. My current workaround is to add something like:
which is annoying for two reasons. The minor one is that having to specify yourself feels a bit silly. The more serious one is that you lose any inter-image caching between |
I'm having the same exact same problem. The workaround with defining an image name within docker-compose and using it as a |
This works if the tag in the build is static, if it's dynamic (git commit hash for example) caching will only work until your HEAD changes. I would love a way to specify cache_from + local, for example |
Let me close this ticket for now, as it looks like it went stale, and this was about the cache-from implementation in the classic builder, which has now been superseded by BuildKit |
Using the new --cache-from is a huge improvement most of the time, but it seems to cause docker to avoid looking in its, for lack of a better term, local cache, meaning that a second build of the same image starts from scratch, or at least from where the remote cache diverges.
https://github.com/docker/docker/blob/master/daemon/cache.go#L12 seems to confirm that this is very much intended.
It would be great to look at the local cache first and only hit the --cache-from images if it doesn't find anything. Or possibly have a way of specifying the local cache as an option, say
docker build --cache-from . myimage:v1.0
It would also be great to document this behavior as part of the
--cache-from
docs. Right now it says "Images to consider as cache sources" but it's unclear that that causes the normal cache to be unconsidered.Thanks!
Steps to reproduce the issue:
Describe the results you received:
The second build starts from the latest step it shares with myimage:v1.0
Describe the results you expected:
The second build re-uses the entire cache from the first build.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
The text was updated successfully, but these errors were encountered: