<aside> 💡
In this chapter, we will use Docker to review the techniques we previously learned, including Network Namespace, Virtual Ethernet, Linux Bridge, and more.
</aside>
<aside> 💡
This environment uses the Ubuntu 24.04 server provided by iximiuz Labs, which offers a fast and convenient online practice environment.
Reference: https://labs.iximiuz.com/
</aside>
Install following the official guide: Docker DocumentationUbuntu
After installation, the Docker service is not enabled by default, so we need to enable it using the following command:
$ sudo systemctl status docker.service
$ sudo systemctl start docker.service
$ sudo systemctl enable docker.service

sudo docker run -d --name <ng1/ng2> nginx to create two nginx Docker containers.docker0 bridge.$ ip route command to check the host’s routing table. You can observe that the docker0 rule, like eth0, is created automatically by the kernel.
Next, let’s enter the network namespaces of the two containers to check the IP addresses assigned to them.
Here, we use the nsenter command to enter the network namespace. If you prefer to use the ip netns approach, you can refer to this article: Docker and Network Namespace
3152 and 3281.sudo nsenter -n -t 3152 to enter the network namespace of the ng1 container. The method for entering ng2 is similar.
ng2 container directly from the ng1 container. The experiment shows that the two containers can communicate with each other.
docker0 bridge from the Host.ng2 container directly from the ng1 container.We can observe that both ARP and ICMP packets are being transmitted and received normally.

As a side note, how can we tell which virtual ethernet interface on the Host corresponds to the container’s network namespace?
From the diagram on the left, we can see that the interface number 12 on the Host (Bottom) corresponds to the eth0 interface inside the container (Up), which also ends with 12.