Skip to content

Conversation

@Pnkcaht
Copy link

@Pnkcaht Pnkcaht commented Jan 14, 2026

What I did

Adjusted how NetworkingConfig.EndpointsConfig is built so that networks are ordered by gw_priority before being sent to the Docker Engine.

Previously, even when gw_priority was defined in the Compose file, the order of endpoints passed to the Engine was non-deterministic due to map iteration.
This change ensures endpoints are explicitly ordered by descending gw_priority, matching the expected Compose semantics and Docker Engine behavior.

A helper function was introduced in defaultNetworkSettings to sort endpoint settings before constructing NetworkingConfig, and a unit test was added to validate the ordering.

Related issue

Fixes #13511

(not mandatory) A picture of a cute animal, if possible in relation to what you did

🐳 Carefully routing containers through the right gateway

Notes

  • No behavior change for single-network services
  • Only affects multi-network services with gw_priority configured
  • Covered by unit test

Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
@Pnkcaht Pnkcaht force-pushed the fix-gw-priority-network-order branch 2 times, most recently from 28d7e90 to 1e3fc17 Compare January 14, 2026 23:54
Copy link
Contributor

@ndeloof ndeloof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orderEndpointsByGwPriority returns a map, so won't fix any ordering issue
Also, AFAIK there's no ordering requirements after the priority attribute has been introduced - this was non determinist before this API change, without any workaround.
Is this PR related to an identified issue or just a tentative fix exploring the codebase?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] gw_priority is ignored on ipv4 network if service also joins an ipv6 network without priority

2 participants