启动Docker注册表后无法访问http://172.17.0.2:5000`

在mac系统上,我按照部署文档启动注册:

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

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

但是我无法远程登录其端口:

$ 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-machine,请参阅“ docker-

machine中的端口转发? ”

  • 任一端口在VirtualBox级别上转发5000端口(这localhost:5000将起作用)

    VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port5000,tcp,,5000,,5000";

  • 或使用由返回的ip $(docker-machine ip <yourMachine>)

以上是 启动Docker注册表后无法访问http://172.17.0.2:5000` 的全部内容, 来源链接: utcz.com/qa/434392.html

回到顶部