Description
Libnetwork currently always allocate/reserve one extra IP address for gateway and there is no way to disable that. My usecase for this is that I want to do simple/lightweight p2p connections between containers so I wanted to create /30 subnets... but that turned out to be not possible as one of two free addresses goes to gateway:
$ docker network create testing --internal --ipv6=false --subnet 10.20.30.0/30
7979a03512757b3819aa1b5c4223899e70da9fca278fd53067ed2d345350bb58
$ docker run --rm -it --network testing alpine:latest sh -c 'ip addr && read'
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
17: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 02:42:0a:14:1e:02 brd ff:ff:ff:ff:ff:ff
inet 10.20.30.2/30 brd 10.20.30.3 scope global eth0
valid_lft forever preferred_lft forever
# In second terminal:
$ docker run --rm -it --network testing alpine:latest sh -c 'ip addr && read'
docker: Error response from daemon: no available IPv4 addresses on this network's address pools: testing (7979a03512757b3819aa1b5c4223899e70da9fca278fd53067ed2d345350bb58).
(In my actual setup I also have custom network driver (especially for creating p2p connectivity via veth pairs) but I don't think it is relevant here.)
Current workaround for this limitation is to either use bigger subnet or write custom hacky IPAM driver that would allow duplicated address but neither of these are ideal.
I had a look at source code too see if it could be changed in some easy way (that I could change/patch myself) but only solution that I could think of is to add new option/label to network objects for this. I also have a feeling that implementing this could also solve #48193.
Description
Libnetwork currently always allocate/reserve one extra IP address for gateway and there is no way to disable that. My usecase for this is that I want to do simple/lightweight p2p connections between containers so I wanted to create /30 subnets... but that turned out to be not possible as one of two free addresses goes to gateway:
(In my actual setup I also have custom network driver (especially for creating p2p connectivity via veth pairs) but I don't think it is relevant here.)
Current workaround for this limitation is to either use bigger subnet or write custom hacky IPAM driver that would allow duplicated address but neither of these are ideal.
I had a look at source code too see if it could be changed in some easy way (that I could change/patch myself) but only solution that I could think of is to add new option/label to network objects for this. I also have a feeling that implementing this could also solve #48193.