以前我使用的是Docker工具包,可以使用 docker-machine inspect <machine-name>
找到docker机器的IP,以便查看容器内所服务的页面。
我已升级到docker beta客户端(对于mac),无法找到提供页面的位置。
我假设因为它是docker pure而不是docker-machine我会在localhost上看到暴露的端口。但他们不公开。即使通过kitematic,我也会导航到暴露的端口(80),但什么也看不见。
$ docker inspect tiny_cori | jq '.[].HostConfig.PortBindings'
{
"80/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
]
}
$ docker inspect tiny_cori | jq '.[].NetworkSettings.IPAddress'
"172.17.0.2"
$ curl 172.17.0.2:80/status
^C
$ docker exec -t -i tiny_cori /bin/bash
root@f1c303f60a15:/# curl localhost:80/status
{"status":"OK"}
root@f1c303f60a15:/# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
link/sit 0.0.0.0 brd 0.0.0.0
3: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN group default qlen 1
link/tunnel6 :: brd ::
4: ip6gre0@NONE: <NOARP> mtu 1448 qdisc noop state DOWN group default qlen 1
link/gre6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
26: eth0@if27: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.2/16 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::42:acff:fe11:2/64 scope link
valid_lft forever preferred_lft forever
172.17.0.2真的是我的容器的IP吗?如果没有,我在哪里可以找到IP是什么?或者我有端口映射问题?