4

On a mac system, I start the register following the deploy document:

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

And its ip is "IPAddress": "172.17.0.2", which is from the command docker inspect <cid>

But I can't telnet its port:

$ telnet 172.17.0.2 5000
Trying 172.17.0.2...
telnet: connect to address 172.17.0.2: Can't assign requested address
telnet: Unable to connect to remote host

Or

$ curl http://172.17.0.2:5000
curl: (7) Couldn't connect to server

I ssh to the container to check it:

$ docker exec -it cda bash
root@cda4c64efd06:/# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp6       0      0 :::5000                 :::*                    LISTEN
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
root@cda4c64efd06:/# curl -I http://localhost:5000
HTTP/1.1 200 OK
Cache-Control: no-cache
Date: Fri, 11 Dec 2015 07:34:17 GMT
Content-Type: text/plain; charset=utf-8

root@cda4c64efd06:/#

Seems like it's binding tcp6 not normally tcp.

Where is wrong?

Freewind
  • 193,756
  • 157
  • 432
  • 708

1 Answers1

3

If you are using docker-machine, see "Port forwarding in docker-machine?"

  • either port forward the 5000 port on the VirtualBox level (meaning localhost:5000 will work)

    VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port5000,tcp,,5000,,5000";
    
  • or use the ip returned by $(docker-machine ip <yourMachine>)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You are right, I should use the ip of the machine! Which is not the ip of the container `172.17.0.2`, but the one which shows when starting "Docker Quickstart Terminal", for now, it's `192.168.99.100` – Freewind Dec 11 '15 at 08:43
  • @Freewind Yes, 172.17.0.2 should be the flannel network created by docker created for container to container communication (https://coreos.com/flannel/docs/latest/flannel-config.html) – VonC Dec 11 '15 at 08:45