'Assigning container a static IP through bridge
I have containers running in VMs in GNS3 as shown below:
The containers are running containerised Ubuntu 20.04, I start the containers using the bridged network option and they can communicate with the other machines. However I need to assign each container it's own static IP as shown in the image. I've tried placing
auto eth0 iface eth0 inet static address 10.10.2.2 netmask 255.255.255.0 gateway 10.10.2.99
in /etc/networks however it doesn't seem to work. The eth0 interface continues to be assigned an IP in the 172.17.0.0/24 range.
Update: I changed the docker daemon.json file on the Ubuntu Desktop host to give the containers an IP in the 10.10.2.0/24 subnet.
{
"bip": "10.10.2.1/24",
"fixed-cidr": "10.10.2.0/25",
"mtu": 0,
"default-gateway": "10.10.2.99"
}
However, now packets from the host aren't reaching the router.
Solution 1:[1]
Solution was to use a Macvlan which assigns a MAC address to each container's virtual network interface.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | qz_99 |


