why is a bridge network driver in docker can be connected by multiple devices?

246 Views Asked by At

I happen to find out that the network component created by command docker network create <name> can be connected by more than 2 containers. And I ran cmd docker network inspect <name> and noticed that the network component was based on 'bridge' driver. Mostly, a bridge has only two port, and working on the Data Link Layer(Layer 2), but the docker bridge network has configuration about gateway IP, subnet IP, and act like a router... why is that?

$ docker network inspect test_net
[
    {
        // ... more ...
        "Driver": "bridge",
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.19.0.0/16",
                    "Gateway": "172.19.0.1"
                }
            ]
        },
        // ... more ...
        "Containers": {
            "179f58df1703141de16910b3da6b5e20d3dacf84ac8ba54dcd056b22fdbb5131": {
                // ... more ...
            },
            "54eef07a7cd456b0e7eb66cb0c382e7209905cffd813d2203316ab676d3850ff": {
                // ... more ...
            },
            "d2019820a6ef143c64d07b40d77e9e6d891834189de12dc57b02d202c5142c32": {
                // ... more ...            }
        }
    }
]

I'm learn docker for the moment, and trying to build a small network with docker container for testing purpose. I need a network component that acts like a physical switch device, with three ubuntu containers connected to it, so that I can inspect the network traffic with tools like tcpdump. But I didn't find any network component running with 'switch' type.

0

There are 0 best solutions below