Cannot visit `http://172.17.0.2: 5000` after starting docker registry

On a Mac, I run the register following the expand document :

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

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

But I can not 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 into 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 :/# 

It seems that this tcp6 binding tcp6 not usually tcp .

Where is it wrong?

+4
source share
1 answer

If you are using a docker machine, see " Port Forwarding on a Docker Machine? "

  • either forward port 5000 at the VirtualBox level ( localhost:5000 value will work)

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

+3
source

Source: https://habr.com/ru/post/1237887/


All Articles