Skip to content

ggcr: registry on localhost is defaulted to docker.io - image not known when accessing image #2048

Open
@maximilianbraun

Description

@maximilianbraun

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions