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

Load metadata even when the image is locally available #5340

Open
ttc0419 opened this issue Sep 18, 2024 · 12 comments
Open

Load metadata even when the image is locally available #5340

ttc0419 opened this issue Sep 18, 2024 · 12 comments

Comments

@ttc0419
Copy link

ttc0419 commented Sep 18, 2024

Hi, even if images in the Dockerfile are available in local storage, buildit still load metadata from docker.io/library, which takes a lot of time:

[internal] load metadata for docker.io/library/xxx:latest

Is there a way to disable it?

@tonistiigi
Copy link
Member

The only request that needs to happen if you have already accessed the image once is a HEAD request that checks if the digest where the latest tag points to has changed or not. It does not actually need to pull in image manifest/config (nor layers) if these have already been accessed.

If you are using buildkit in dockerd or with a containerd worker you can override it by pulling image with the same name to the image store (and not setting --pull on build), but note that your builds can become stale then and it is up to you to frequently pull newer versions of the image to the image store.

@thaJeztah
Copy link
Member

I guess related;

Would implementing that be an option for this?

@tonistiigi
Copy link
Member

@thaJeztah The version described there that is missing is --pull=never that does not seem to be related to this issue. BuildKit never performs a "docker pull", --pull defines the behavior of BuildKit resolving an image from a registry or some image store.

@thaJeztah
Copy link
Member

Perhaps from a pure technical perspective, but I'd consider "contacting the registry" to be a "pull" from a user perspective; --pull=never to be a "don't contact registry; use offline" mode

@tonistiigi
Copy link
Member

to be a "don't contact registry; use offline" mode

That's not what your definition is in the proposal. There is means "error if there is no local image". "don't contact registry; use offline" is the default (but you need to have offline version of the image).

@thaJeztah
Copy link
Member

But BuildKit pulls the image and checks the registry if it's up to date??

I understand the build-cache with BuildKit may not store it in the list of images. But (really!) from the user's perspective it's pulling an image.

If we don't consider that an image, then we must update all our docs, because they're wrong; https://docs.docker.com/reference/dockerfile/#from

IMG_1281

@tonistiigi
Copy link
Member

But BuildKit pulls the image and checks the registry if it's up to date??

No, it does not if you have an image with that name already.

If we don't consider that an image, then we must update all our docs, because they're wrong;

🤷‍♂️ BuildKit 100% deals with images and takes image names as input. Images are in the registry or in image stores.

@ttc0419
Copy link
Author

ttc0419 commented Sep 20, 2024

to be a "don't contact registry; use offline" mode

That's not what your definition is in the proposal. There is means "error if there is no local image". "don't contact registry; use offline" is the default (but you need to have offline version of the image).

I meant do not contact the registry in any way, because the reason I want to use the local image only is because the registry might not be reachable. Even only loading the metadata makes it pointless. Is it possible?

@tonistiigi
Copy link
Member

tonistiigi commented Sep 20, 2024

@ttc0419 It is possible with docker or containerd that can keep local snapshots of the images for you. See #5340 (comment)

It is also possible if you use immutable image references with digest checksums.

@ttc0419
Copy link
Author

ttc0419 commented Sep 20, 2024

@ttc0419 It is possible with docker or containerd that can keep local snapshots of the images for you. See #5340 (comment)

It is also possible if you use immutable image references with digest checksums.

I know it can store the image snaphosts and not to "pull" it, I meant is it possible not to send the HEAD request? Because some of my images are built by myself, checking them with the registry does not make any sense.

@tonistiigi
Copy link
Member

Storing the image snapshot is how you avoid sending the HEAD request.

@ttc0419
Copy link
Author

ttc0419 commented Sep 20, 2024

Storing the image snapshot is how you avoid sending the HEAD request.

But my problem was it still sends the HEAD request when the image is already stored in the local registry. What I want is disable version checking for local images that have latest tags.

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

3 participants