Minidcos:无法使用主机名在Docker容器之间进行通信

时间:2019-04-10 13:56:28

标签: docker networking docker-networking dcos

我正努力在minidcos使用主机名创建的两个docker容器之间进行通信。这是我所做的:

第1步:创建新的docker网络

$ docker network create minidcos

步骤2:创建新的minidcos集群:

$ minidcos docker create
  --docker-version 17.12.1-ce 
  --agents 4 
  --workspace-dir ./workspace
  --network minidcos 
  --genconf-dir ./custom-genconf 
  --verbose 
  ./dcos_generate_config.sh

第3步:列出容器

$ docker ps

89d2861fd037        mesosphere/dcos-docker   "/sbin/init"        31 minutes ago      Up 31 minutes                           dcos-e2e-default-d67b8-public-agent-0
33d0c83c07d7        mesosphere/dcos-docker   "/sbin/init"        31 minutes ago      Up 31 minutes                           dcos-e2e-default-d67b8-agent-3
221e9ecd4464        mesosphere/dcos-docker   "/sbin/init"        31 minutes ago      Up 31 minutes                           dcos-e2e-default-d67b8-agent-2
ef7dbf33fc53        mesosphere/dcos-docker   "/sbin/init"        31 minutes ago      Up 31 minutes                           dcos-e2e-default-d67b8-agent-1
b1994b77dce0        mesosphere/dcos-docker   "/sbin/init"        31 minutes ago      Up 31 minutes                           dcos-e2e-default-d67b8-agent-0
dc46644e391e        mesosphere/dcos-docker   "/sbin/init"        31 minutes ago      Up 31 minutes                           dcos-e2e-default-d67b8-master-0

第4步:验证我的自定义“ minidcos”网络

$ docker network inspect minidcos
[
    {
        "Name": "minidcos",
        "Id": "b105cbfe91228334b52406a2ccf53c2fdfc085b5030b9203684dd78a44f67d1c",
        "Created": "2019-04-10T14:06:03.493606395+02:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "221e9ecd44648e5729d00b1d3fb5c677c499c3a181b06f76656e4404dca4ebca": {
                "Name": "dcos-e2e-default-d67b8-agent-2",
                "EndpointID": "073b3b6a35b555463893daf271cf2de367205ab0826fbbf82d6be46367d4d9f9",
                "MacAddress": "02:42:ac:13:00:05",
                "IPv4Address": "172.19.0.5/16",
                "IPv6Address": ""
            },
            "33d0c83c07d7abe49fbdbacff68027e0f162ccf66fb348b3df8fa28216872d3d": {
                "Name": "dcos-e2e-default-d67b8-agent-3",
                "EndpointID": "e8ac563a652f5d69a740a75e1a9ba374ab648698d8d0e449abc23eed2b3f6359",
                "MacAddress": "02:42:ac:13:00:06",
                "IPv4Address": "172.19.0.6/16",
                "IPv6Address": ""
            },
            "89d2861fd037a5dce81fa0079d445531328cc1b22650c80add5bf72c985dce0b": {
                "Name": "dcos-e2e-default-d67b8-public-agent-0",
                "EndpointID": "6e5cd6d75bd96922ea1e98360520849e1b459948fe68fbba5b4a7e7d5a8db68d",
                "MacAddress": "02:42:ac:13:00:07",
                "IPv4Address": "172.19.0.7/16",
                "IPv6Address": ""
            },
            "b1994b77dce008ef5c28f634ad14cfcbb69dc6c14ee530a784533ad09c9f8d58": {
                "Name": "dcos-e2e-default-d67b8-agent-0",
                "EndpointID": "4adc52ff6a64afd79d33c9b40559c9ff4c5086f12d7c82d26206ab876908b84e",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            },
            "dc46644e391e4e9cc2978c534ab9eae91db31cff3f3d06e54a4870049fe080ab": {
                "Name": "dcos-e2e-default-d67b8-master-0",
                "EndpointID": "9460ea8a07722d5de337ad8375f452218b54462b5e1a98def7590725415fa09a",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            },
            "ef7dbf33fc53d06ada2a29a6637c22a294263182a060a4ef35db365dd2fbaf17": {
                "Name": "dcos-e2e-default-d67b8-agent-1",
                "EndpointID": "228253db88795489a228bf9da7132475f4146b357dabff43ca6d009072e864ee",
                "MacAddress": "02:42:ac:13:00:04",
                "IPv4Address": "172.19.0.4/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {}
    }
]

现在,据我了解,我应该能够通过其主机名对每个容器执行ping操作。但这出于某些原因不起作用。例如,我无法从dcos-e2e-default-d67b8-agent-0 ping dcos-e2e-default-d67b8-agent-1

[root@dcos-e2e-default-d67b8-agent-1 /]# ping dcos-e2e-default-d67b8-agent-0
ping: dcos-e2e-default-d67b8-agent-0: Name or service not known

那是为什么?可能是DC / OS阻止了docker解析主机名吗?

更新

我使用docker create将另一个普通的fedora容器添加到了相同的“ minidcos”网络中。从这个容器中,我可以按其主机名ping所有其他容器。猜猜确实是DC / OS破坏了主机名解析...

0 个答案:

没有答案