Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have 2 containers configured to run an application which communicates with each other. the docker-compose.yaml file looks like this :-

version: "2"
services:
  node1:
    image: docker_app1
    command: tail -F anything
    ports:
      - "5500:5500"

  node2:
    image: docker_app2
    command: tail -F anything
    depends_on:
      - node1

i run the application and started the communication between the 2 apps via port 5500 and i can see both container connected to the bridge network.

$ sudo docker network inspect dm_default                   

    
[

    
    {

    
        "Name": "dm_default",

    
        "Id": "7680f509b5634217c2402d52675dede9469bfd8e45838005d6543ed0c0160a75",

    
        "Created": "2021-01-09T12:39:55.567336Z",

    
        "Scope": "local",

    
        "Driver": "bridge",

    
        "EnableIPv6": false,

    
        "IPAM": {

    
            "Driver": "default",

    
            "Options": null,

    
            "Config": [

    
                {

    
                    "Subnet": "172.20.0.0/16",

    
                    "Gateway": "172.20.0.1"

    
                }

    
            ]

    
        },

    
        "Internal": false,

    
        "Attachable": true,

    
        "Ingress": false,

    
        "ConfigFrom": {

    
            "Network": ""

    
        },

    
        "ConfigOnly": false,

    
        "Containers": {

    
            "cb061a4e71d9e235675b32583ef8be20f96e88731d84d97285c362477e179747": {

    
                "Name": "node1",

    
                "EndpointID": "acb6b5441391b70b943bf1f5e69f224ebe7346dee56f02842918f3ea558fa321",

    
                "MacAddress": "02:42:ac:14:00:02",

    
                "IPv4Address": "172.20.0.2/16",

    
                "IPv6Address": ""

    
            },

    
            "d74c5daf1dbd95cae307ad57ced0816fd8b8bf4ea7f52f2a8d5fdd4fa9db2fa2": {

    
                "Name": "node2",

    
                "EndpointID": "e49f683ab1f8042325402ddfd7a96f6c430c19966581e10035a634ecb706a0bd",

    
                "MacAddress": "02:42:ac:14:00:03",

    
                "IPv4Address": "172.20.0.3/16",

    
                "IPv6Address": ""

    
            }

    
        },

    
        "Options": {},

    
        "Labels": {

    
            "com.docker.compose.network": "default",

    
            "com.docker.compose.project": "dm",

    
            "com.docker.compose.version": "1.27.4"

    
        }

    
    }

    
]

I want to simulate a network disconnection on one of the container so i did

$ sudo docker network disconnect dm_default node2

and i verified that the node2 container is not in the network anymore

$ sudo docker network inspect dm_default                      

    
[

    
    {

    
        "Name": "dm_default",

    
        "Id": "7680f509b5634217c2402d52675dede9469bfd8e45838005d6543ed0c0160a75",

    
        "Created": "2021-01-09T12:39:55.567336Z",

    
        "Scope": "local",

    
        "Driver": "bridge",

    
        "EnableIPv6": false,

    
        "IPAM": {

    
            "Driver": "default",

    
            "Options": null,

    
            "Config": [

    
                {

    
                    "Subnet": "172.20.0.0/16",

    
                    "Gateway": "172.20.0.1"

    
                }

    
            ]

    
        },

    
        "Internal": false,

    
        "Attachable": true,

    
        "Ingress": false,

    
        "ConfigFrom": {

    
            "Network": ""

    
        },

    
        "ConfigOnly": false,

    
        "Containers": {

    
            "cb061a4e71d9e235675b32583ef8be20f96e88731d84d97285c362477e179747": {

    
                "Name": "node1",

    
                "EndpointID": "acb6b5441391b70b943bf1f5e69f224ebe7346dee56f02842918f3ea558fa321",

    
                "MacAddress": "02:42:ac:14:00:02",

    
                "IPv4Address": "172.20.0.2/16",

    
                "IPv6Address": ""

    
            }

    
        },

    
        "Options": {},

    
        "Labels": {

    
            "com.docker.compose.network": "default",

    
            "com.docker.compose.project": "dm",

    
            "com.docker.compose.version": "1.27.4"

    
        }

    
    }

    
]

However, my application inside node1 and node2 is still communicating with each other. ( network disconnect simulation failed. ) is there any reason this is so? or how I can trace the issue?

Thanks

question from:https://stackoverflow.com/questions/65644560/i-cant-simulate-a-network-disconnection-from-docker-container

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
463 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...