How to set static IP address to a container running into a Swarm over a weave-overlay network?

1.1k views Asked by At

TL;DR: bug present in Swarm 1.0.0, solved in Swarm 1.1.0.

On a four swarm agents cluster, a custom overlay network is run with the weave plugin:

user@swarm-master:~$swarm-docker network create --driver weave --subnet 192.168.0.0/16 custom-weave

However, with this command and its output we can see an issue:

user@swarm-master:~$ swarm-docker run --rm -it --net=custom-weave --ip=192.168.0.5 debian:jessie bash -c "ip addr     show"
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    [ . . ]
74: ethwe0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1410 qdisc noqueue state UP group default 
    link/ether ee:c2:9c:6c:c3:6c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.2/16 scope global ethwe0
       valid_lft forever preferred_lft forever
    inet6 fe80::ecc2:9cff:fe6c:c36c/64 scope link tentative 
       valid_lft forever preferred_lft forever
76: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state DOWN group default 
    [ . . ]

The user defined --net option is set as well as --ip=192.168.0.5. While the container is expected to have its ethwe0 interface IP address set to 192.168.0.5, it is actually set to 192.168.0.2.

Question: What is wrong with this process?

Nothing, just a bug solved since the version 1.1.0.

1

There are 1 answers

0
Auzias On BEST ANSWER

As stated by vieux on this GH issue, this is a bug in Swarm 1.0.0. This bug has been solved in the Swarm 1.1.0.