获取Docker网络的主机名/ ip

时间:2017-05-09 23:13:28

标签: docker docker-networking docker-network

我有这个:

# create network
docker network create cdt-net

如何获取此Docker网络的本地IP /主机名“cdt-net”?

使用docker network inspect cdt-net,我得到:

[
    {
        "Name": "cdt-net",
        "Id": "0c2bd01e2192a82fc5472e28b966b3692720ab902bfa99e8d4c6c825a13f8f11",
        "Created": "2017-05-09T23:33:52.632492853Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Containers": {
            "0f9dd64a2aafc95bdb9ea8cdbb2ab136d492426b421ee56780175d5710de5d32": {
                "Name": "cdt-selenium",
                "EndpointID": "ad5348e3fa445d241e0acec094c09f75c40ee8d0edcbe988f7ecbe43fb183c4a",
                "MacAddress": "02:42:ac:12:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": ""
            },
            "3c4d5394b42e444f313c3a8d2743e7564abfd65df66bf76cc22c676ca8e94861": {
                "Name": "cdt-mongo",
                "EndpointID": "5aa64d19e4eb429606b46826e616b391a27aebe794d8c945ef0af17ab34c3e57",
                "MacAddress": "02:42:ac:12:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            },
            "c9d0f5f1e5dbbe0be309ac0fa4b1620aca0b32e12b5f50027df541d6a519332b": {
                "Name": "cdt-server",
                "EndpointID": "7dbebd7e58c4c6579ebd0fcef54a86f22ae4696864fc783d3fcc9d953c949397",
                "MacAddress": "02:42:ac:12:00:04",
                "IPv4Address": "172.18.0.4/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

但是从那时起,我仍然不确定如何通过IP从容器外部访问其中一个容器。这可能吗?

0 个答案:

没有答案