Docker Container (C50) - Host Networking vs Bridge Networking
search cancel

Docker Container (C50) - Host Networking vs Bridge Networking

book

Article ID: 246035

calendar_today

Updated On:

Products

AppNeta

Issue/Introduction

The following articles provides details of the differences between host networking and bridge networking for AppNeta Container Monitoring Points (CMP).

Resolution

Host Networking vs Bridge Networking

Bridge mode is the default mode of networking enabling great flexibility to shift container workloads between hosts easily. The container uses an automatically assigned private IP address (Docker normally takes care of DNS too). Containers on the same bridge can talk to each other.

In this mode you can view the IP address of the primary network interface of the container.   For example, if you have the following scenario:

root@<hostname>: sudo docker exec -it ba2c53b58e62 /bin/bash
root@<hostname>: ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.x.x  netmask 255.255.0.0  broadcast 172.16.x.x
        ether 02:xxxxxxxx0:02  txqueuelen 0  (Ethernet)
        RX packets 315352  bytes 28212974 (26.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 314701  bytes 82837363 (78.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

As well as the bridge interface of the host:

 

root@<hostname>:~$ sudo ip addr
...
37: br-122b5f8b8d14: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:xxxxxxx:c2 brd ff:ff:ff:ff:ff:ff
    inet 172.16.x.1/16 brd 172.16.255.255 scope global br-122b5f8b8d14
       valid_lft forever preferred_lft forever
    inet6 fe80::xxxxxx:dec2/64 scope link
       valid_lft forever preferred_lft forever
...

 

 

 

Host mode means the container's network stack is not isolated from the host's. This mode is only available on Linux.

Verifying networking mode in a running container

 

docker container inspect <pathview-cmp container id> | grep "NetworkMode"

Bridge Networking result:
$ sudo docker inspect ba2c53b58e62 | grep "NetworkMode"
            "NetworkMode": "<hostname>",

Host Networking result:
$ sudo docker inspect ba2c53b58e62 | grep "NetworkMode"
						"NetworkMode": "host",