简体   繁体   中英

Docker Container not able to access in localhost and also same network segment

New to docker, please correct my statement I'm trying to access docker container ex:nginx web server using port 80 in docker engine machine but am unable to access it.

Here my docker Engine network 10.20.20.0/24.

Docker Engine IP : 10.20.20.3

> Telnet 10.20.20.3 80  Connection failed
    tcp        0      0 10.20.20.3:80       0.0.0.0:*               LISTEN      28953/docker-proxy

Docker Container IP : 172.18.0.4

> Telnet 172.18.0.4 80  Connection success

Docker network detail

[root@xxxxxxxxx]# docker network inspect 1984f08c739d [
    {
        "Name": "xxxxxxxxxxxxx",
        "Id": "1984f08c739d6d6fc6b4769e877714844b9e57ca680f61edf3a528bd12ca5ad1",
        "Created": "2021-11-13T21:01:27.53591809+05:30",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.18.0.0/16",
                    "Gateway": "172.18.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "126d5128621fa6cde0389f4c6e0b53be36670bce5f62e981da6e17722b88c4a9": {
                "Name": "xxxxxxxxxxxxxxx",
                "EndpointID": "b011052062ae137e3d190032311e0fbc5850f0459c9b24d8cc1d315a9dc18773",
                "MacAddress": "02:42:ac:13:00:02",
                "IPv4Address": "172.18.0.4/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "xxxxxxxx",
            "com.docker.compose.version": "1.29.2"
        }
    } ]

I can access these nginx in other networks like 10.20.21.0/24 so on. But not on the same network 10.20.20.0/24 or same docker engine running on it.

My Environment Docker Engine VM having 2 Interfaces ie eth0 and eth1 with different subnet. In Previously it'll not work because both interfaces having separate routing table in /etc/sysconfig/network-scripts (route-eth0,route-eth1 and rule-eth0,eth1) Base hyper-v AHV. These route written to persistent interface. I tried to removing route for eth0. Since eth0 doesnt required routing table to persistent, it'll come by default route table in Linux. Then restarted the network..Hola there we go the docker listening on eth0 interfaces and something did for eth1. it's worked. Both eth0 and eth1 interfaces I can map to the dockers network. It's work like charm. I believe in AHV doesnt not required routing table for AHV VMs for different and same network subnets. So here the concluded its routing issues. Issues was resolved, I can access docker container with eth0,eth1 interfaces across different subnets and same subnet.

Both interfaces worked after restarting without any routes in AHV VMs and power off.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM