buildx: --cache-from fails if cache does not already exist
could not read /tmp/buildx-cache/index.json: open /tmp/buildx-cache/index.json: no such file or directory
docker buildx build \
--cache-from type=local,src=/tmp/buildx-cache \
--cache-to type=local,dest=/tmp/buildx-cache \
.
Is --cache-from only supported when the cache already exists? That behavior would make no sense!
What am I missing?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 23
- Comments: 17 (4 by maintainers)
Hi I’m using
and I still get the same issue…
and when I build, I get:
Do you have any idea for a workaround?
Tried with the master branch, but the problem persists.
This is a warning to let you know that nothing was loaded. It does not fail your build.
The reason why it’s broken is when you use
--cache-fromand--cache-totogether, this line fails https://github.com/moby/buildkit/blob/master/client/solve.go#L432 if you run --cache-to on its own first, it will generate the json file and then you can add --cache-from after.However this workaround is not feasible in e.g. CI/CD multibranch workflows, and should be fixed.
docker buildx create --driver docker-container --driver-opt image=moby/buildkit:master,network=host --usedocker buildx bakecould not read .app-docker-cache/index.json: open .app-docker-cache/index.json: no such file or directoryWith docker-bake.hcl containing:
this was fixed in https://github.com/moby/buildkit/pull/1285
You can switch to master build with
--driver-optif you want to use it now. https://github.com/docker/buildx#--driver-opt-options