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

ggcr: Expected error when parsing name reference that is an Image ID #1953

Open
picatz opened this issue May 30, 2024 · 0 comments
Open

ggcr: Expected error when parsing name reference that is an Image ID #1953

picatz opened this issue May 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@picatz
Copy link

picatz commented May 30, 2024

Describe the bug

The name.ParseReference function treats a local "Image ID" reference as a name.Tag, instead of returning an error.

To Reproduce

imageID := "sha256:0505a58fa4646ca8c19699d99a1053c789d00d9424ee9d8ed4d988e7642d1672"

name, err := name.ParseReference(imageID)
// err is nil, name is a tag

registry := name.Context().RegistryStr()
// "index.docker.io"

repo := name.Context().RepositoryStr()
// "library/sha256"

tag := name.Context().Tag(name.Identifier()).TagStr()
// "0505a58fa4646ca8c19699d99a1053c789d00d9424ee9d8ed4d988e7642d1672"

Expected behavior

I would expect name.ParseReference to return an error.

Additional context

The "Image ID" is a valid local image reference that can be run with docker run, but not something we can pull from a registry, because it's neither a tag or digest.

📃 Click for more details demonstrating the difference between "Image ID", "Image Digest", and "Image Tag".

We have an ubuntu:latest image pulled, with sha256:77906da… as the (remote) image digest, and sha256:2b7cc08… as the local image ID.

$ docker images --digests --no-trunc
REPOSITORY       TAG       DIGEST            IMAGE ID          CREATED         SIZE
ubuntu           latest    sha256:77906da…   sha256:2b7cc08…   2 months ago    69.2MB

We can run our ubuntu:latest image by specifying the same digest we have locally:

$ docker run --rm -it ubuntu@sha256:77906da…
root@69a36beaf024:/# exit

Of course, we cannot specify that image ID as the digest, because it's not the same thing:

$ docker run --rm -it ubuntu@sha256:2b7cc08…
Unable to find image 'sha256:2b7cc08…' locally
docker: Error response from daemon: manifest for ubuntu@sha256:2b7cc08…  not found: manifest unknown: manifest unknown.
See 'docker run --help'.

We can specify just the Image ID of our local ubuntu:latest:

$ docker run --rm -it sha256:2b7cc08…     
root@c29f22dc1dd9:/# exit

Then, just for fun, we can't specify just the digest, because the daemon won't know which image you're referring to:

$ docker run --rm -it sha256:77906da…
docker: Error response from daemon: No such image: 
sha256:77906da…
See 'docker run --help'.
@picatz picatz added the bug Something isn't working label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant