Skip to content
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

Error on cache query #569

Closed
slamdev opened this issue Aug 12, 2018 · 12 comments
Closed

Error on cache query #569

slamdev opened this issue Aug 12, 2018 · 12 comments

Comments

@slamdev
Copy link

slamdev commented Aug 12, 2018

Image is failing to build when --cache-from flag is passed to docker build:

$ ls
Dockerfile	file.txt
$ cat Dockerfile
FROM nginx:alpine
COPY file.txt /opt/
$ DOCKER_BUILDKIT=1 docker build --cache-from nginx:alpine .
[+] Building 6.8s (6/7)
 => local://context (.dockerignore)                                                                                                                                                                                                      0.0s
 => => transferring context: 02B                                                                                                                                                                                                         0.0s
 => local://dockerfile (Dockerfile)                                                                                                                                                                                                      0.0s
 => => transferring dockerfile: 81B                                                                                                                                                                                                      0.0s
 => ERROR importing cache manifest from docker.io/library/nginx:alpine                                                                                                                                                                   6.8s
 => local://context                                                                                                                                                                                                                      0.0s
 => => transferring context: 29B                                                                                                                                                                                                         0.0s
 => docker-image://docker.io/library/nginx:alpine                                                                                                                                                                                        0.0s
 => => resolve docker.io/library/nginx:alpine                                                                                                                                                                                            0.0s
 => docker-image://docker.io/tonistiigi/copy:v0.1.3@sha256:e57a3b4d6240f55bac26b655d2cfb751f8b9412d6f7bb1f787e946391fb4b21b                                                                                                              0.0s
 => => resolve docker.io/tonistiigi/copy:v0.1.3@sha256:e57a3b4d6240f55bac26b655d2cfb751f8b9412d6f7bb1f787e946391fb4b21b                                                                                                                  0.0s
------
 > importing cache manifest from docker.io/library/nginx:alpine:
------
error on cache query: invalid build cache from docker.io/library/nginx:alpine

I am not sure should the issue be posted here or in https://github.com/docker/cli

@manishtomar
Copy link

Does this happen again? Maybe temporary glitch trying to get nginx:alpine manifest?

@tonistiigi
Copy link
Member

The value of --cache-from has changed in buildkit and it now points to a special build cache manifest that buildkit can export. We have discussed inlining metadata for the image layers to the experted image config as well to keep some compatibility with current logic but it is not implemented yet.

@tiborvass I think we should at least suppress this error.

@RytisLT
Copy link

RytisLT commented Sep 10, 2018

@tonistiigi in #62 (comment) you've mentioned that

buildkit already should support exporting cache to any registry

How can I achieve that? Pushing an image built with buildkit doesn't seem to do it. Is there and extra parameter for docker build to push cache to registry?

Edit: found that it's a current limitation of experimental implementation (moby/moby#37151)

@nielskrijger
Copy link

Tried building an image with buildkit using --cache-from and noticed the same error as described in this issue.

If I understood correctly I was expecting that when the --cache-from image was built using buildkit it should work. Instead I noticed auth errors while using private registries:

$ docker build --cache-from gcr.io/my-project/my-service:builder  .

=> ERROR importing cache manifest from gcr.io/my-project/my-service:builder                                                                                                                                                                                                                                      2.2s
 => [internal] load build context                                                                                                                                                                                                                                                                                0.1s
 => => transferring context: 21.71kB                                                                                                                                                                                                                                                                             0.0s
 => [internal] helper image for file operations                                                                                                                                                                                                                                                                  0.1s
 => => resolve docker.io/tonistiigi/copy:v0.1.4@sha256:d9d49bedbbe2b27df88115e6aff7b9cd11ed2fbd8d9013f02d3da735c08c92e5                                                                                                                                                                                          0.1s
 => [builder 1/11] FROM docker.io/library/golang:1.11-alpine3.8                                                                                                                                                                                                                                                  0.0s
 => => resolve docker.io/library/golang:1.11-alpine3.8                                                                                                                                                                                                                                                           0.0s
 => CANCELED [builder 2/11] RUN apk add --no-cache git build-base openssh                                                                                                                                                                                                                                        0.7s
------
 > importing cache manifest from gcr.io/my-project/my-service:builder:
------
rpc error: code = Unknown desc = error on cache query: unexpected status code https://gcr.io/v2/my-project/my-service/manifests/builder: 401 Unauthorized

Tried a different repository (Gitlab), and got a 403 instead:

 => ERROR importing cache manifest from registry.gitlab.com/my-project/my-service:builder                                                                                                                                                                                                                         0.6s
 => [builder 1/11] FROM docker.io/library/golang:1.11-alpine3.8                                                                                                                                                                                                                                                  0.0s
 => => resolve docker.io/library/golang:1.11-alpine3.8                                                                                                                                                                                                                                                           0.0s
 => [internal] load build context                                                                                                                                                                                                                                                                                0.0s
 => => transferring context: 21.71kB                                                                                                                                                                                                                                                                             0.0s
 => [internal] helper image for file operations                                                                                                                                                                                                                                                                  0.1s
 => => resolve docker.io/tonistiigi/copy:v0.1.4@sha256:d9d49bedbbe2b27df88115e6aff7b9cd11ed2fbd8d9013f02d3da735c08c92e5                                                                                                                                                                                          0.1s
 => CANCELED [builder 2/11] RUN apk add --no-cache git build-base openssh                                                                                                                                                                                                                                        1.0s
------
 > importing cache manifest from registry.gitlab.com/my-project/my-service:builder:
------
rpc error: code = Unknown desc = error on cache query: failed to fetch anonymous token: unexpected status: 403 Forbidden

Pushing and pulling works just fine on both registries.

@RytisLT
Copy link

RytisLT commented Sep 24, 2018

@nielskrijger the problem is that BuildKit uses a different cache format. To use --cache-from with BuildKit you need to export BuidKit cache first. Unfortunately, it's currently impossible with docker build (moby/moby#37151). You would need to use BuidKit directly to export the cache.

@nielskrijger
Copy link

Thank you @RytisLT for explaining it again. It finally "clicked" what the your previous comment was about... and I am starting to understand the difficulty of the problem.

Is it possible to make the error more clear in these circumstances?

Existing v2 registries fetching cache manifests built with Buildkit are now returning (401, 403) it seems. Similarly the invalid build cache error found by @slamdev could be more clear; more akin to "this build cache format is not supported by ...".
Alternatively (or in addition to) I'm wondering if upon a push to an incompatible registry the user should be warned if certain features/data are lost.

@lig
Copy link

lig commented Jul 31, 2019

I'd expect this behavior to be implemented using a new command-line argument and the old --cache-from to have the same behavior as before. At least failing with not implemented error. This would make much more sense.
The current behavior just makes migration to buildkit a lot more complicated.

@tonistiigi
Copy link
Member

This has been fixed by inline cache support #777 (in Docker 19.03)

@jeffreybrowning
Copy link

@tonistiigi can we post a link to relevant documentation to how this issue is fixed by #777

@zengqingfu1442
Copy link

I still come across this error when run CI pipeline in gitlab and gitlab registry. Is there any workaround for this error? @tonistiigi @RytisLT @manishtomar thanks

@javierguzman
Copy link

javierguzman commented Mar 28, 2021

Hello @zengqingfu1442 I am getting this issue. Did you solve it at the end? Thank you in advance and regards.

p.s. I see it has been solve in version 19.03 ok I will give it a try

@zengqingfu1442
Copy link

Upgrade your docker version to the latest 20.10.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants