当主机上的VPN为ON时,容器上的Internet无法访问

时间:2018-06-06 14:29:01

标签: docker

当我这样做时

docker run -i -t --privileged busybox ping google.com

当我的主机上的VPN关闭时它起作用,但是当我启动它时它失败了。

我使用

找到了我的DNS服务器地址
sudo systemd-resolve --status | grep "DNS Server"

我尝试在docker容器中使用它,它给出了:

docker run -i -t --privileged --dns=192.168.1.254 busybox nslookup google.com
Server:    192.168.1.254
Address 1: 192.168.1.254

Name:      google.com
Address 1: 2607:f8b0:4020:804::200e yul02s04-in-x0e.1e100.net
Address 2: 172.217.13.206 yul03s05-in-f14.1e100.net

所以它可以找到域名的IP地址,但我仍然无法对其进行ping操作。

当我使用--network host选项时,它可以工作,但我遇到其他容器的问题。

当VPN关闭时,这是我的/etc/resolv.conf文件:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 8.8.8.8
nameserver 127.0.0.53
search telus

当它开启时:

nameserver  8.8.8.8
nameserver  8.8.4.4
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

search telus

以下是有关容器使用的网络的信息:

[
    {
        "Name": "project_default",
        "Id": "e5b5cdaf12ea277f28b5e5a050041a55fe33d279bcd6b2c737a3a6cdfb039ea2",
        "Created": "2017-10-05T21:24:16.200249606+02:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "03af7eb1bcfb394c436784974603ad72667610a8a2bba6f8ec3ca87a3eecc733": {
                "Name": "project_mongo_1",
                "EndpointID": "6567c3ad72fba3d2d4519d6aa47ac9fc7d65d2b6884f91aa70f4041ba2fc98cc",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.19.0.2/16",
                "IPv6Address": ""
            },
            "13dce3db104e2dafb2ebbdceeefe1a5ca8559808c050a9e95d4abae5b2203b54": {
                "Name": "project_redis_1",
                "EndpointID": "fb5abe7b896fb9d5f635cd30cbc57ad721e184c36a754bffce696b7f7fc1fbfc",
                "MacAddress": "02:42:ac:13:00:05",
                "IPv4Address": "172.19.0.5/16",
                "IPv6Address": ""
            },
            "3f301bd0973637ac4440f9f9bfc8f6d2fdf4d3bf048ab95c9db91ef03dc4cde1": {
                "Name": "dimelo_faye_server",
                "EndpointID": "90eda817636ce87123882187cea629c63419712816fbf952364959fd6d41f25b",
                "MacAddress": "02:42:ac:13:00:06",
                "IPv4Address": "172.19.0.6/16",
                "IPv6Address": ""
            },
            "530c61bfde2a21812ae3b677f0a019805a1dcea21722d181648defd0037de7f3": {
                "Name": "project_elasticsearch_1",
                "EndpointID": "a8cd9df941907c4abfb5762fe6af5069cfa6e97259d2d5c1c9992f269f6b444a",
                "MacAddress": "02:42:ac:13:00:03",
                "IPv4Address": "172.19.0.3/16",
                "IPv6Address": ""
            },
            "5e615627d664bf5cad7b31f5594bc64730dca46ae8c80bb12b0ee881dac8bfb1": {
                "Name": "project_memcache_1",
                "EndpointID": "b7388f26c1aaedb98ebc6d3eac018d713e0c914bc4d6a84501358cc126be1105",
                "MacAddress": "02:42:ac:13:00:04",
                "IPv4Address": "172.19.0.4/16",
                "IPv6Address": ""
            },
            "6b143aa84d6fd55245b462220a4dab4f54c9d365ab4a1e7c7823265b53432bbb": {
                "Name": "project_web_run_53",
                "EndpointID": "964311691aefff57c9ad5898b1153c8a166575193c25babad575e9990092e911",
                "MacAddress": "02:42:ac:13:00:08",
                "IPv4Address": "172.19.0.8/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "project"
        }
    }
]

当VPN处于开启状态时,如何才能在容器上访问Internet?

0 个答案:

没有答案