Docker Community Forums

Share and learn in the Docker community.

Give Two IP of the same network to a container

Hello,
I am building a CI/CD for a CDN which is using anycast.
I would like to give two ip of the same docker network to an ubuntu 18.04 container.
For example I created this network:

docker network create -d bridge --subnet 192.168.242.0/24 --gateway 192.168.242.1 test_net

Now I connect my container to this network when I run it by adding --network test_net --ip 192.168.242.2
At this point my container have ip 192.168.242.2 on eth0.

How can I give ip 192.168.242.3 on eth1 for example on an ubuntu 18.04 container image ?
When I run docker network connect test_net my_container, I got an error because my container is already attached to this network. I also tried to give two --ip flag at the creation of the container but it doesn’t work too.

Moreover how can I add a loopback ip to my container ? for example lo:1 2.2.2.2 netmask 255.255.255.255

Thanks for your help