Skip to content

Fix Docker host port allocation races - #209

Open
chatton wants to merge 3 commits into
mainfrom
cian/issue-208-port-collisions
Open

chatton wants to merge 3 commits into
mainfrom
cian/issue-208-port-collisions

Conversation

@chatton

@chatton chatton commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

There has been a recurring issue with duplicate port allocations, it seems like there was a bug in the most recent "fix", looking at the release notes for the docker engine here it looks like by allowing docker to assign a port itself, it will no longer collide so we should be able to remove all the locks and safeguards we had in place around it.

The exception is when re-creating containers. (stopping/starting) they are now preserved, so existing references to those ports remain valid.

Ran test multiple times, all passing.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 6feeb1b9-7a80-45d0-a5cf-7be803721b0f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment on lines +110 to +111
pS[port] = struct{}{}
pb[port] = []network.PortBinding{{HostIP: localhost}}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

there was an issue in the docker client itself in the past where there was some overlap of ports, but it was supposed to be fixed here so allowing the docker engine to choose should now be safe again.

@chatton
chatton marked this pull request as ready for review September 28, 2026 14:11
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.95122% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.18%. Comparing base (8641781) to head (8945144).

Files with missing lines Patch % Lines
framework/docker/container/lifecycle.go 22.50% 60 Missing and 2 partials ⚠️
framework/docker/cosmos/broadcaster.go 0.00% 1 Missing ⚠️
framework/docker/cosmos/node.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main    #209      +/-   ##
========================================
+ Coverage   8.20%   9.18%   +0.98%     
========================================
  Files         87      87              
  Lines       6317    6371      +54     
========================================
+ Hits         518     585      +67     
+ Misses      5707    5687      -20     
- Partials      92      99       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatton
chatton requested a review from rootulp October 1, 2026 12:32
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.

3 participants