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

question: How manually configure the go-containerregistry client to use HTTP when accessing a registry #1874

Open
WikiHkz opened this issue Feb 5, 2024 · 2 comments
Labels
question Further information is requested

Comments

@WikiHkz
Copy link

WikiHkz commented Feb 5, 2024

When accessing a container image registry using go-containerregistry, I notice different behavior when using a domain name versus an IP address.

When using a domain name like registry.example.com, the client first tries to connect over HTTPS on port 443. If this is rejected, the client exits with an error.

However, when using an IP address like 10.0.0.1, it also first tries HTTPS and port 443. But if that is rejected, it then tries a second attempt over HTTP on port 80. This succeeds and the connection is established.

Why does the client try falling back to HTTP when an IP address is used, but it does not make a second attempt for a domain name?

Is there a way I can manually configure the go-containerregistry client to use HTTP when accessing a registry, instead of relying on the automatic HTTPS fallback behavior?

// image, err := name.ParseReference("registry.storm.io/image:v1")
image, err := name.ParseReference("10.xx.xx.198/image:v1")
img, err := remote.Image(image,remote.WithAuth(authn.FromConfig(authn.AuthConfig{Username: authfig.Username, Password: authfig.Password}))) 

At the same time, I also noticed that my registry does not seem to support https access.
If I use docker pull to pull the image, it will fail and the error message is:

Error response from daemon: Get "https://10.xx.xx.198/v2/": dial tcp 10.xx.xx.198:443: connect: connection refused

If I modify "insecure-registries" in /etc/docker/daemon.json, for example

"insecure-registries" : [
     "registry.storm.io"
   ]

docker pull pulls the image successfully.

@WikiHkz WikiHkz added the question Further information is requested label Feb 5, 2024
@WikiHkz WikiHkz closed this as completed Feb 5, 2024
@WikiHkz WikiHkz reopened this Feb 5, 2024
@WikiHkz WikiHkz closed this as completed Feb 5, 2024
@WikiHkz WikiHkz reopened this Feb 5, 2024
@testwill
Copy link

I encountered the same problem

@testwill
Copy link

image, err := name.ParseReference("10.xx.xx.198/image:v1", name.Insecure)
Just add name.Insecure Option and it should be fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants