-
Notifications
You must be signed in to change notification settings - Fork 543
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
getting image ID (sha) takes longer than docker cli #627
Comments
It might make sense to use the docker client directly? There's The reason this is really slow is that our Something like this should work: func getImageID(ctx context.Context, ref string) (string, error) {
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
return "", err
}
cli.NegotiateAPIVersion(ctx)
img, err := cli.ImageInspectWithRaw(ctx, ref)
if err != nil {
return "", err
}
return img.ID, nil
} Hopefully that's sufficient for what you're trying to do? If you're trying to use go-containerregistry to accomplish something more complicated, and this is slowing everything down, we could also look at optimizing that use case by specializing the |
@jonjohnsonjr I was hoping to not depend on docker cli exist in the path. I need this for implementing kic (kuberntes in container) in minikube kubernetes/minikube#5987 in which we will need a faster way of loading image from host to the minikube node (but avoid loading the duplicate images don't load if sha exists) |
I don't think the snippet I posted above requires the CLI on the path, just the github.com/docker/docker/client dependency, which it looks like minikube already depends on.
This is an interesting problem that's particularly bad with docker: moby/moby#38446 IMO the cleanest way to solve this is to run a registry in-cluster to avoid having to serialize images to tarballs in the first place... some related discussion in kind: kubernetes-sigs/kind#602 |
@jonjohnsonjr thanks for the response, yeah we like to provide both ways of registry and loading the image for various reasons, such as offline minikube experience,... if I use the docker cli lib, I wonder if that would work nice with users who use crio or podman as their default OCI .... I doubt that docker support it. (but my undrestanding is go-containerregistery) would would work regardless of that |
Probably not, I'm sure you'd have to do something different for each runtime |
This issue is stale because it has been open for 90 days with no |
@medyagh it looks like you worked around this. Is this still something you want fixed? |
We still need to do it, but will not use docker daemon - since it might not be available. Most likely with some file hack, with deploying a registry server as the "real" solution. i.e. store the digest in a separate file, when available
and cache the id, to not have to recompute it from tar
and resolve the server, to avoid issues with non-docker runtimes
and then add the platform to the path, to avoid arch collisions
Now all we have to do is fix is the stupid old file format, and add some real compression to it... https://www.cyphar.com/blog/post/20190121-ociv2-images-i-tar "What's Wrong with Tar?" |
This issue is stale because it has been open for 90 days with no |
I am trying to find a cheap way to get the image SHA, if I do docker inspect it takes 0.07 s
however if I use go-containerregistry it will take 4s,
is there any cheaper way to get the image ID using go-containerregistry ?
I also tried crane.Digest that still takes 2.1 seconds.
Update: I also tried getting it through config but it is still 1.95 seconds
code:
time
This would be an important improvment for iterative development on minikube. when users constantly rebuild an image and push.
The text was updated successfully, but these errors were encountered: