2

I am facing issues when I try to push to registry that I created earlier. Here are the steps that I followed.

docker run -d -p 5001:5002 --restart=always --name new_registry registry:2

docker build -t test-app .

docker run -p 50100:8080 -d --name app test-app
docker tag test-app localhost:5001/test:latest
docker push localhost:5001/test:latest

=================================================

 ✘  ~/G/S/d/a/App   master   docker push localhost:5001/test:latest
The push refers to a repository [localhost:5001/test] (len: 1)
Sending image list
Put http://localhost:5001/v1/repositories/test/: net/http: transport closed before response was received

Below is output of docker images command:

  ~/G/S/d/a/App   master   docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
test-app              latest              78f9362f7cd5        51 minutes ago      547.8 MB
localhost:5001/test   latest              78f9362f7cd5        51 minutes ago      547.8 MB
registry              2                   5d165b8e4b20        3 weeks ago         220.1 MB

More Details Below:

 ~/G/S/d/a/patterns_and_tools  docker-machine env default
set -x DOCKER_TLS_VERIFY "1";
set -x DOCKER_HOST "tcp://192.168.yyy.xxx:2376";
set -x DOCKER_CERT_PATH "/Users/zack/.docker/machine/machines/default";
set -x DOCKER_MACHINE_NAME "default";
# Run this command to configure your shell:
# eval (docker-machine env default)
 ~/G/S/d/a/patterns_and_tools 

I checked the network settings in the VM . They are as below:

Name : dockersetting protocol : TCP HOST IP: HOST PORT : 50100 GuestIP : Guest Port : 50100

Zack
  • 2,078
  • 10
  • 33
  • 58

1 Answers1

1

A tag boot2docker (even though it has been obsoleted by docker machine) means you are not on Linux directly, but on Windows or Mac, using a Linux VM.

You have a similar error message reported in issue 523 of docker/distribution (the new registry server)

When you bind to localhost inside the container, the service won't be available outside the container, even though you are specifying the port mapping.
When the docker daemon goes to connect, it cannot connect to the port since the service is not bound to the "external" interface of the container.

That means you need to setup port forwarding, or to use the docker-machine ip new_registry ip address.

docker push $(docker-machine ip new_registry):5001/test:latest

5000:5000 works but 5001:5002 does not work when creating registry.

It is possible that the VM was already set to port forward port 5000, but not 5001 (similar to this picture).

It means the registry image exposes port 5000: you can map that on host port 5000 or 5001 or any port you want: but it has to be port 5000 that you map:

docker run -d -p 5001:5000 --restart=always --name new_registry registry:2
                      ^^^^
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • how do I check if the VM is already set to forward port 5000 but not 5001? – Zack Nov 14 '15 at 20:33
  • @Zack by looking at http://odewahn.github.io/docker-jumpstart/images/vboxmanage.png: the network setting of the VM. – VonC Nov 14 '15 at 20:35
  • The default is right now port 2376. I added more details to my question : output of "docker-machine env default" command which spits out the host ip address followed by port number – Zack Nov 14 '15 at 20:37
  • @Zack Got it. I have found the right explanation and have edited the answer accordingly. – VonC Nov 14 '15 at 20:42
  • Ohh. How did you figure that out ? Yeah. Even I thought so that 5000 seems to be set somewhere. – Zack Nov 14 '15 at 20:46
  • @Zack yes, 5000 from registry is set by the Dockerfile which specifies how to build the registry image. – VonC Nov 14 '15 at 20:47
  • Okay. I am testing this out and will mark your answer soon. Thanks – Zack Nov 14 '15 at 20:47