2015-12-11 49 views
4

在Mac系統後,我開始寄存器以下的deploy document不能訪問`HTTP://172.17.0.2:5000`開始搬運工註冊表

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 
[email protected]:/# 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 
[email protected]:/# 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 

[email protected]:/# 

好像它結合tcp6無法正常tcp

哪裏出錯?

+0

這些說明適用於Linux ,而不是OSX。你在使用docker-machine還是boot2docker? –

+0

是的,'docker'命令正在運行'docker machine' – Freewind

回答

3

如果您正在使用泊塢窗機,請參閱 「Port forwarding in docker-machine?

  • 任一端口轉發在VirtualBox的水平的5000端口(意思localhost:5000將工作)

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

+0

你說得對,我應該使用機器的ip!這不是容器'172.17.0.2'的ip,而是啓動「Docker Quickstart Terminal」時顯示的那個,現在是'192.168.99.100' – Freewind

+0

@Freewind是的,172.17.0.2應該是創建的法蘭絨網絡通過docker爲容器創建容器通信(https://coreos.com/flannel/docs/latest/flannel-config.html) – VonC