Creating macvlan network with single IP address range works, but attaching container fails.
Create network:
$ docker network create -d macvlan \
--subnet 192.168.34.0/24 \
-o parent=eth0 \
--ip-range 192.168.34.54/32 \
eth0-test
3b413e03b6de671c20c48cdeb07562c42a220b983d464a467a6be8492ff5eb8c
Create container:
$ docker run -it --detach=false --network eth0-test ubuntu:latest
docker: Error response from daemon: no available IPv4 addresses on this network's address pools: eth0-test (3b413e03b6de671c20c48cdeb07562c42a220b983d464a467a6be8492ff5eb8c).
Ultimate goal, to have predefined IP address assigned to container like above and further more to service, like below:
Host1:
$ docker network create --config-only \
--subnet 192.168.34.0/24 \
-o parent=eth0 \
--ip-range 192.168.34.2/32 \
eth0-net
Host2:
$ docker network create --config-only \
--subnet 192.168.34.0/24 \
-o parent=eth0 \
--ip-range 192.168.34.3/32 \
eth0-net
Host-any:
$ docker network create -d macvlan \
--scope swarm --config-from eth0-net eth0-swarm-net
$ docker service create --mode global --name test-service \
--network eth0-swarm-net ubuntu:latest sleep infinity
Such service container will acquire IP 192.168.34.2 when started on host1, and 192.168.34.3 when started on host2.
Service not necessarily should be global, it could be replicated with sticky docker host configuration, guaranteeing only one instance attaching to network eth0-swarm-net per docker host.
Thus achieving static IP address assignment on per host / container basis in swarm mode.
Docker version:
$ docker version
Client:
Version: 18.06.0-ce
API version: 1.38
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:11:02 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.0-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: 0ffa825
Built: Wed Jul 18 19:09:05 2018
OS/Arch: linux/amd64
Experimental: false
Creating
macvlannetwork with single IP address range works, but attaching container fails.Create network:
Create container:
Ultimate goal, to have predefined IP address assigned to container like above and further more to service, like below:
Host1:
Host2:
Host-any:
Such service container will acquire IP 192.168.34.2 when started on
host1, and 192.168.34.3 when started onhost2.Service not necessarily should be global, it could be replicated with sticky docker host configuration, guaranteeing only one instance attaching to network
eth0-swarm-netper docker host.Thus achieving static IP address assignment on per host / container basis in swarm mode.
Docker version: