Interconnecting two or more containers
Using our knowledge from the previous section, we should be aware that two or more containers that have been created inside the same network can reach each other on the same subnet without the need for external routing.
At the same time, two or more containers that belong to different networks will be able to reach each other on different subnets by routing packets through their networks.
To demonstrate this, let's create a couple of busybox
containers in the same default network:
# podman run -d --name endpoint1 \ --cap-add=net_admin,net_raw busybox /bin/sleep 10000 # podman run -d --name endpoint2 \ --cap-add=net_admin,net_raw busybox /bin/sleep 10000
In our lab, the two containers have 10.88.0.14
(endpoint1
) and 10.88.0.15
(endpoint2
) as their addresses. These two addresses are subject to change and can be collected using the methods illustrated previously with the podman inspect
or the nsenter
commands...