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: registry on localhost is defaulted to docker.io - image not known when accessing image #2048

Open
maximilianbraun opened this issue Jan 28, 2025 · 0 comments

Comments

@maximilianbraun
Copy link

maximilianbraun commented Jan 28, 2025

Hi!

thanks for the great work done here.

Describe the bug

When i.e leveraging podman images are tagged with localhost as default registry [1]. Docker used docker.io.
When calculating an images size [2] based on the locally tagged name, resolution will fail[3] because of defaulting back to docker.io. since localhost is not honnored as a relevant registry name.

I barely remember it, but i think containerd is defaulting to localhost as well (?)

As far as I can see, https://github.com/google/go-containerregistry/blob/main/pkg/name/repository.go#L81 could be the relevant line of code.

With docker the same behaviour works well, since docker uses internally docker.io as a registry name.

To Reproduce

  • Use Podman
  • Build docker image [1]
  • Run Test [2]

Expected behavior

I would expect that a valid hostname, like localhost, is accepted as a registry

Additional context

Add any other context about the problem here.

  • Version of the module: github.com/google/go-containerregistry v0.20.2
  • Registry used (e.g., GCR, ECR, Quay)
❯ podman --version
podman version 5.3.2

[1]

❯ cat Dockerfile
FROM scratch
❯ docker build . -t testimage:mytag
STEP 1/1: FROM scratch
COMMIT testimage:mytag
--> 379ecbdbbcdc
Successfully tagged localhost/testimage:mytag
379ecbdbbcdcb68e330f76f5928b8aaf37f1a5f13f63d1684a572fa4c7655965

[2]

func Test(t *testing.T) {
	refName := "localhost/testimage:mytag"
	reference, err := name.ParseReference(refName)
	assert.NoError(t, err)
	image, err := daemon.Image(reference)
	assert.NoError(t, err)
	_, err = image.Size()
	assert.NoError(t, err)
}

[3]

=== RUN   Test
    ...test.go:176: 
        	Error Trace:	...test.go:176
        	Error:      	Received unexpected error:
        	            	Error response from daemon: docker.io/library/testimage:mytag: image not known
        	Test:       	Test
--- FAIL: Test (0.01s)

FAIL
@maximilianbraun maximilianbraun changed the title ggcr: localhost is defaulted to docker.io - image not known when accessing image ggcr: registry on localhost is defaulted to docker.io - image not known when accessing image Jan 28, 2025
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

1 participant