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?
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)or use the ip returned by
$(docker-machine ip <yourMachine>)