Skip to content

Assign static IPs from upper subnet range#53

Merged
firecow merged 2 commits intomainfrom
assign-high-ips-on-overlay-networks
Feb 12, 2026
Merged

Assign static IPs from upper subnet range#53
firecow merged 2 commits intomainfrom
assign-high-ips-on-overlay-networks

Conversation

@firecow
Copy link
Copy Markdown
Member

@firecow firecow commented Feb 11, 2026

  • Picks IPs from the top of overlay network subnets to avoid collisions with Swarm IPAM
  • Deterministic index per container (sorted by name) prevents IP races on the same node
  • Skips already-used IPs across all swarm nodes via NetworkInspect
  • Falls back to Docker default if IP selection fails
  • Modernizes helpers with samber/lo and stdlib slices

@firecow firecow self-assigned this Feb 11, 2026
When connecting containers to overlay networks, pick IPs from the top
of the subnet (broadcast-1, -2, ...) instead of letting Docker IPAM
assign from the bottom. Each container gets a deterministic index based
on sorted name, preventing IP races between containers on the same node.
Already-used IPs across all swarm nodes are skipped via NetworkInspect.

Also modernizes helpers using samber/lo and stdlib slices.
@firecow firecow requested a review from staal0 February 11, 2026 22:14
@firecow firecow force-pushed the assign-high-ips-on-overlay-networks branch from b473c26 to 8954ea8 Compare February 11, 2026 22:14
Copy link
Copy Markdown
Contributor

@staal0 staal0 left a comment

Choose a reason for hiding this comment

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

LGTM

@firecow
Copy link
Copy Markdown
Member Author

firecow commented Feb 12, 2026

I ran a test locally, and the containers do get assigned IP's in the top of the range. I'm releasing new version.

image

@firecow firecow merged commit 435b8fa into main Feb 12, 2026
6 checks passed
@firecow firecow deleted the assign-high-ips-on-overlay-networks branch February 12, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants