Skip to content

How to export cache in buildkit #699

@ms-choudhary

Description

@ms-choudhary

I can't seem to figure out how to export cache from buildkit to registry/local. There seems no documentation around on how to do that.

I tried following unsuccessfully:

bash-4.4# buildctl build --export-cache registry --export-cache-opt name=docker.io/mschoudhary/hello-world --export-cache-opt push=true --frontend=dockerfile.v0 --local context=. --local dockerfile=. 
[+] Building 6.2s (10/10) FINISHED
 => [internal] load .dockerignore                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                              0.0s
 => [internal] load build definition from Dockerfile                                                                                                                         0.0s
 => => transferring dockerfile: 32B                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/golang:alpine                                                                                                             2.8s
 => [internal] helper image for file operations                                                                                                                              0.0s
 => => resolve docker.io/tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089                                                      0.0s
 => [build 1/3] FROM docker.io/library/golang:alpine@sha256:ccb871525d23b7ae5be6a159841fb3b4b5dc5c789ce36489bd9ef83c9ca0b93b                                                 0.0s
 => => resolve docker.io/library/golang:alpine@sha256:ccb871525d23b7ae5be6a159841fb3b4b5dc5c789ce36489bd9ef83c9ca0b93b                                                       0.0s
 => [internal] load build context                                                                                                                                            0.0s
 => => transferring context: 28B                                                                                                                                             0.0s
 => CACHED [build 2/3] COPY main.go .                                                                                                                                        0.0s
 => CACHED [build 3/3] RUN go build -o /bin/hello .                                                                                                                          0.0s
 => CACHED [release 1/1] COPY --from=build /bin/hello .                                                                                                                      0.0s
 => ERROR exporting cache                                                                                                                                                    3.4s
 => => preparing build cache for export                                                                                                                                      0.0s
 => => writing layer sha256:3aaf202967879d295dd06275ef7322bc20087424938d4fbcf196cf2d693c1d4e                                                                                 3.3s
------
 > exporting cache:
------
error: failed to solve: rpc error: code = Unknown desc = error writing layer blob: server message: insufficient_scope: authorization failed

There is no indication of what's wrong here. (I'm able to successfully push image to registry) Would be grateful if someone could help with this.

Buildkit client version:

bash-4.4# buildctl --version
buildctl github.com/moby/buildkit 0.0.0 fb5324c609465f9b0713cbce5f8a36eb119be144

Buildkit daemon version:

bash-4.4# buildkitd --version
buildkitd github.com/moby/buildkit 0.0.0 fb5324c609465f9b0713cbce5f8a36eb119be144

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions