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 5 years ago
  • Reactions: 15
  • Comments: 17 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Hi I’m using

$ docker buildx version
github.com/docker/buildx v0.8.2-docker 6224def4dd2c3d347eee19db595348c50d7cb491

and I still get the same issue…

target "front" {
  inherits = ["defaults"]
  context="."
  tags = tag("nginx")
  cache-from = [
    "user/app:cache",
    "type=local,src=/tmp/buildx-cache"
  ]
  cache-to = ["type=local,dest=/tmp/buildx-cache"]
}

and when I build, I get:

$ docker buildx bake -f ./build.hcl --progress plain --push
[...]
 > importing cache manifest from user/app:cache:
------
------
 > exporting to image:
------
WARNING: local cache import at /tmp/buildx-cache not found due to err: could not read /tmp/buildx-cache/index.json: open /tmp/buildx-cache/index.json: no such file or directory

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.

this was fixed in https://github.com/moby/buildkit/pull/1285

You can switch to master build with --driver-opt if you want to use it now. https://github.com/docker/buildx#--driver-opt-options