I have containers running inside swarm which which I wanted to assign a fixed ip on the host network.
I have defined following setup:
service 1
version: "3"
services:
openhab:
image: openhab/openhab:2.4.0
hostname: openhab
networks:
- monitor
- proxy
- oh-macvlan
........
service 2
version: "3"
services:
sb-server:
image: lukics/sb-server:armv7
ports:
- 9000:9000
- 9090:9090
- 3483:3483
hostname: sb-server
networks:
- monitor
- proxy
- sb-macvlan
.....
on each swarm node:
docker network create --config-only --subnet 192.168.3.0/24 --gateway 192.168.3.1 --ip-range 192.168.3.168/32 -o parent=eth0 oh-config
docker network create --config-only --subnet 192.168.3.0/24 --gateway 192.168.3.1 --ip-range 192.168.3.169/32 -o parent=eth0 sb-config
on the swarm:
docker network create -d macvlan --scope swarm --config-from oh-config oh-macvlan
docker network create -d macvlan --scope swarm --config-from sb-config sb-macvlan
network ls:
d1ad0251dddf oh-config null local
1govxjctvgvi oh-macvlan macvlan swarm
ja6ycy1tft1x proxy overlay swarm
a60b23eb3fbd sb-config null local
r8zq4fojpewg sb-macvlan macvlan swarm
I have realised that after a while, when the services a moved from one node to the other or restarted i get following error:
$ docker service ps sb-server_sb-server --no-trunc
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
vrzfexarv9e9tip2of4xc6lgn sb-server_sb-server.1 lukics/sb-server:armv7@sha256:40563d0bfa476cee0d62659e6d2430aa24ab8d6c9fe4e65f915575c691151500 vevedock-03 Running Running 2 hours ago
41dl7sq5hfd5vqmt5n3voym71 \_ sb-server_sb-server.1 lukics/sb-server:armv7@sha256:40563d0bfa476cee0d62659e6d2430aa24ab8d6c9fe4e65f915575c691151500 vevedock-02 Shutdown Rejected 3 hours ago "network dm-r8zq4fojpewg is already using parent interface eth0"
The service sb-server_sb-server uses the sb-macvlan (r8zq4fojpewg) network. When the service started on vevedock-02 node error prevented start: network dm-r8zq4fojpewg is already using parent interface eth0.
This network dm-r8zq4fojpewg is persistent on this node and prevents fron this point on starting this service on this node.
I read in the forums that following might help, though a no go for me:
Removing /var/lib/docker/network/files/local-kv.db and restarting docker fixes the issue.
any idea how to fix this by better means?