'Docker compose networking - Priority property ignored
I composed docker-compose.yaml file which contains 4 network interfaces, these interfaces needs to be in a specific order when mounted to the docker container.
Docker Engine Version: 19.03
Docker-compose Version: 2.4.1
we're using macvlan driver as part of our system in order to have L2 packets transfer between host interfaces.
and the docker container we're using to host everything on is based on ubuntu:18.04
networks:
sim1:
name: sim1
driver: macvlan
driver_opts:
parent: ens20
macvlan_mode: bridge
ipam:
config:
- subnet: 192.3.0.0/16
ip_range: 192.3.1.0/24
sim2:
name: sim2
driver: macvlan
driver_opts:
parent: ens21
macvlan_mode: bridge
ipam:
config:
- subnet: 192.4.0.0/16
ip_range: 192.4.1.0/24
sim3:
name: sim1
driver: macvlan
driver_opts:
parent: ens20
macvlan_mode: bridge
ipam:
config:
- subnet: 192.5.0.0/16
ip_range: 192.5.1.0/24
sim4:
name: sim1
driver: macvlan
driver_opts:
parent: ens20
macvlan_mode: bridge
ipam:
config:
- subnet: 192.6.0.0/16
ip_range: 192.6.1.0/24
I saw that there's a property called: priority, this property allows to organize the network interfaces according to a metrics you specify on the compose.yaml file.
priority indicates in which order Compose implementation SHOULD connect the service’s containers to its networks. If unspecified, the default value is 0.
When trying to apply this priority feature on the yaml file I'm getting no errors and no warnings, just ignored on the docker side, and when executing ifconfig I see that the interfaces got in a wrong order.
This is the output of the ifconfig (after filter the results)
eth0: sim1
eth1: sim4
eth2: sim3
eth3: sim2
services:
app1:
image: nginx:latest
command: "tail -f /dev/null"
networks:
sim1:
priority: 1000
sim2:
priority: 900
sim3:
priority: 800
sim4:
priority: 700
I've been searched the internet without any luck and saw that there's a lot of peoples who came across this without any luck.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
