启动Dockerregistry后,无法访问“http://172.17.0.2:5000”

在Mac系统上,我在部署文档之后启动registry:

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

而它的ip是"IPAddress": "172.17.0.2" ,它来自命令docker inspect <cid>

但是我不能telnet它的端口:

 $ 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 

要么

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

我ssh的容器来检查它:

 $ 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:/# 

好像它是绑定tcp6不正常tcp

哪里错了?

如果您正在使用docker机,请参阅“ docker机中的端口转送? ”

  • 任一端口在VirtualBox级别转发5000端口(意思是localhost:5000将工作)

     VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port5000,tcp,,5000,,5000"; 
  • 或使用由$(docker-machine ip <yourMachine>)返回的$(docker-machine ip <yourMachine>)