moby / libnetwork

networking for containers
Apache License 2.0
2.15k stars 880 forks source link

[feature request] virtual IP for bridge network #2477

Open sergey-safarov opened 4 years ago

sergey-safarov commented 4 years ago

Description I have started multiple copy of apache daemon. Daemons configured to use non local IP address. Now I want use floating IP feature for daemons redundant. Say if one demon died, then orchestration daemon assign floating IP to other container.

When I try attach secondary IP to container i get error

$ docker network connect --ip 192.168.54.22 test-net test-pod
Error response from daemon: endpoint with name test-pod already exists in network test-net

Could you allow secondary IP to containers or allow containers have multiple network interfaces to same network.

Steps to reproduce the issue: Create user defined network

$ docker network create --subnet 192.168.55.0/24 test-net
65ca95fa63cc0e251be4ef74d47c9bddac85cfe588d6233119477fcd4b4e619c

Create new container

$ docker run -d --name test-pod --network test-net alpine:edge sleep 1000000
76435b80c5e7076c1bfb2b57cb72f08619ac7eda373d141ab7ff810c37797005

Check network interfaces in continer

[safarov@safarov-dell kamailio-upstream]$ docker exec test-pod ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:C0:A8:37:02  
          inet addr:192.168.55.2  Bcast:192.168.55.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:81 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:9781 (9.5 KiB)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Try assign secondary IP address

$ docker network connect --ip 192.168.55.22 test-net test-pod
Error response from daemon: endpoint with name test-pod already exists in network test-net

Describe the results you received: I cannot assign secondary IP address to container network interface.

Describe the results you expected: I can able assign secondary IP address to container network interface.

sergey-safarov commented 4 years ago

Look as https://github.com/moby/moby/issues/24170 related Could you extend services with virtual IP for bridge, macvlan, ipvlan networks.

sergey-safarov commented 4 years ago

Think more safe for bridge, macvlan, ipvlan use simple secondary ip address.