Docker Community Forums

Share and learn in the Docker community.

Unable to get private Docker Registry to work locally, works remotely

docker

(Kurbar0) #1

Summary

I’ve set up a registry container on a Debian host running on the default port 5000.

The Debian host runs as a virtual machine on top of a VMWare system. Port 5000 is open.

docker run -d -p 5000:5000 --name registry --restart=always registry:2

I then tagged an image for pushing to the registry

docker tag test-image localhost:5000/kp/testing:1.0.0

and tried pushing it

docker push localhost:5000/kp/testing:1.0.0

but it fails with Get http://localhost:5000/v2/: net/http: request canceled (Client.Timeout exceeded while awaiting headers).

The output from the registry container comes up empty. As if the request never reaches it.

What I tried

I then tried to cURL the _catalog endpoint and it just gets stuck when receiving response headers, the connection itself seems to be successful.

curl -v http://localhost:5000/v2/_catalog
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET /v2/_catalog HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.52.1
> Accept: */*
>

I also tried creating a hostname for the registry on the host machine and setting that as the registry connection address but that ended in the same result.

In addition, I also tried adding the hostname to the insecure-registries array in /etc/docker/daemon.json but still ends with the same error.

I then tried setting it up with TLS using a self-signed certificate. Again, the connection seems to be established in cURL but no response headers are received.

I also tried running the container using sudo but that didn’t have any effect either.

Works remotely

Out of curiosity, I tried accessing it remotely so I cURL’ed the same address with the Debian host IP and it works!

curl -v http://<host-ip>:5000/v2/_catalog
*   Trying <host-ip>...
* TCP_NODELAY set
* Connected to <host-ip> (<host-ip>) port 5000 (#0)
> GET /v2/_catalog HTTP/1.1
> Host: <host-ip>:5000
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Docker-Distribution-Api-Version: registry/2.0
< X-Content-Type-Options: nosniff
< Date: Tue, 09 Jan 2018 07:30:30 GMT
< Content-Length: 20
<
{"repositories":[]}

To the question

It seems really unrealistic for it to not work locally on Debian as I’ve set it up using localhost on both a MacOS and an Arch Linux machine. I don’t think the VMWare system could be interfering with local connectivity, especially if it works remotely?

Have I missed something which is preventing the registry to be accessible locally?


(Aldoborrero) #2

I’m facing the same exact problem you were having (I did all the steps above also but nothing) :frowning:


(Aldoborrero) #3

I’ve tried with different options but if you put 127.0.0.1 instead of using localhost and is working.


(Huangfan) #4

same problem, any solution?


(jay_liao) #5

comment out /etc/hosts
" # ::1 localhost "