Closed rodriciru closed 10 months ago
I don't know GO-lang and I can't test it, but maybe the issue is in this line: https://github.com/docker/compose/blob/f5e3ff03f085e430264d1b237481780d92ef3911/pkg/compose/convergence.go#L619
This cfgs.Host.NetworkMode
doesn't feel right to me comparing to mobyNetworkName
I think NetworkMode
has something like host, bridge.. and mobyNetworkName something like anetbork, bnetwork....
network priority is not about visualization, but about the order container get network interfaces connected. This is implemented by https://github.com/docker/compose/blob/main/pkg/compose/convergence.go#L613-L626
Screen captures you attached just demonstrates UI orders alphabetically
I'm not an IT guy, so first I will assume that the first network it should be eth0
. Please tell me if I'm wrong
According to that the priority network should be:
test_cnetwork
with MAC 02:42:ac:14:00:02
test_dnetwork
with MAC 02:42:ac:16:00:02
test_anetwork
with MAC 02:42:ac:1d:00:02
test_bnetwork
with MAC 02:42:ac:1e:00:02
And instead is:
test_anetwork
with MAC 02:42:ac:1d:00:02
test_bnetwork
with MAC 02:42:ac:1e:00:02
test_cnetwork
with MAC 02:42:ac:14:00:02
test_dnetwork
with MAC 02:42:ac:16:00:02
I am wrong?
Here show default is eth0
but then it displays network in correct order:
priority
was first introduced to fix https://github.com/docker/compose/issues/5042 and the intent is to define which of the networks should be considered a target, especially regarding mac_address
which only applies once (see https://github.com/docker/compose/issues/5261). There's no assumption here on the way engine will allocate virtual network devices.
By the way, the original issue now has a better fix with https://github.com/compose-spec/compose-spec/pull/435 and use of priority
becomes irrelevant.
Do you have a concrete issue you'd like to investigate regarding network priorities ?
So priority doesn't indicate the order of network to connect to?
it does, but this doesn't have the technical effects you expect here. Can you please describe your actual issue ?
My issue is that traefik proxy attaches to the first alphabetical network, so if is not the proxy network, I cannot reach them. Also, UFW I have a similar issue, I don't remember exactly as I don't use any more, but it only gets the first network.
That's why I think something is wrong. 2 services always pick the first alphabetical network, even with priorities? Too extrange.
AFAICT traeffic let you select the network to use for service proxying: https://doc.traefik.io/traefik/providers/docker/#network
You can either set thin in traeffic config or set traefik.docker.network
label on your containers
It attaches to first alphabetical network of docker compose networks names. I already have set the label at provider level, so in theory it should pick the right one. Yesterday it happens with mailcow, 2 networks (mailcow default and proxy network) it always connect to mailcow as it first in alphabetiacl order. Change mailcow network name to zzmailcow, and it works...
sounds like a Traeffic bug then. Network priorities as set in compose.yaml
has no expected impact on ordering listing networks for a container, which Traeffic relies on. You should contact maintainers to ask for guidance
What about this, its exactly the same issue: https://github.com/docker/compose/issues/8561
Description
Network priorities are ignored and it takes an alphabetical order
Steps To Reproduce
Compose Version
Docker Compose version v2.23.3
Docker Environment
linux and windows minimum
Anything else?
No response
Viz command output as it should (first bnetwork:, second anetwork