Skip to content

Conversation

@ilopezluna
Copy link
Contributor

Address #526 by providing the command to disable DD TCP:

Starting model runner container docker-model-runner...
Error: unable to initialize standalone model runner container: failed to start container docker-model-runner: Error response from daemon: ports are not available: exposing port TCP 127.0.0.1:12434 -> 127.0.0.1:0: listen tcp4 127.0.0.1:12434: bind: address already in use

The port may already be in use by Docker Desktop's model runner.
Try running: docker desktop disable model-runner

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ilopezluna, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the user experience when encountering port binding conflicts during container startup. By detecting specific port-in-use errors, the system can now provide a more actionable and user-friendly error message, guiding users directly to a potential solution rather than just reporting a generic failure. This change aims to reduce user frustration and streamline troubleshooting for common setup issues.

Highlights

  • New Error Detection Function: Introduced a new helper function, isPortBindingError, to specifically identify common port binding errors, including 'ports are not available' and 'address already in use' or 'Only one usage of each socket address'.
  • Improved Error Messaging: Enhanced the error message returned when CreateControllerContainer fails due to a port binding issue. The new message now includes a suggestion to run docker desktop disable model-runner to resolve the conflict, specifically addressing scenarios where Docker Desktop's model runner might be using the port.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The isPortBindingError check relies on matching specific substrings in the error message, which is brittle across Docker versions/localizations; consider checking for typed errors or well-known error codes if available instead of string contains.
  • The enhanced error message doesn't indicate which port/host failed; including the actual host:port values in the user-facing message would make it clearer which binding is conflicting.
  • The returned error string mixes fmt.Errorf formatting with embedded newlines, which can be hard to log and wrap consistently; consider returning a single-line error and letting the caller handle multi-line user guidance or using a dedicated error type for user hints.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `isPortBindingError` check relies on matching specific substrings in the error message, which is brittle across Docker versions/localizations; consider checking for typed errors or well-known error codes if available instead of string contains.
- The enhanced error message doesn't indicate which port/host failed; including the actual `host:port` values in the user-facing message would make it clearer which binding is conflicting.
- The returned error string mixes `fmt.Errorf` formatting with embedded newlines, which can be hard to log and wrap consistently; consider returning a single-line error and letting the caller handle multi-line user guidance or using a dedicated error type for user hints.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ilopezluna ilopezluna requested a review from a team January 23, 2026 12:43
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves the error handling for port binding failures by detecting when a port is already in use and providing a more informative error message to the user. This is a great enhancement for user experience. The implementation introduces a helper function to check for specific error strings and then uses it to return a custom error. My review includes a couple of suggestions to improve maintainability by extracting hardcoded strings into constants.

Comment on lines +293 to +301
func isPortBindingError(err error) bool {
if err == nil {
return false
}
errStr := err.Error()
return strings.Contains(errStr, "ports are not available") &&
(strings.Contains(errStr, "address already in use") ||
strings.Contains(errStr, "Only one usage of each socket address"))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve readability and maintainability, it's a good practice to extract magic strings into named constants. This makes the code easier to understand and modify in the future.

func isPortBindingError(err error) bool {
	if err == nil {
		return false
	}
	const (
		portBindingErrorStr        = "ports are not available"
		addressInUseErrorStr       = "address already in use"
		socketAddressUsageErrorStr = "Only one usage of each socket address"
	)
	errStr := err.Error()
	return strings.Contains(errStr, portBindingErrorStr) &&
		(strings.Contains(errStr, addressInUseErrorStr) ||
			strings.Contains(errStr, socketAddressUsageErrorStr))
}

Comment on lines 568 to 570
if isPortBindingError(err) {
return fmt.Errorf("failed to start container %s: %w\n\nThe port may already be in use by Docker Desktop's model runner.\nTry running: docker desktop disable model-runner", controllerContainerName, err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve code clarity and make long strings more manageable, consider defining this error format string as a constant.

		if isPortBindingError(err) {
			const portInUseErrorFmt = "failed to start container %s: %w\n\nThe port may already be in use by Docker Desktop's model runner.\nTry running: docker desktop disable model-runner"
			return fmt.Errorf(portInUseErrorFmt, controllerContainerName, err)
		}

errStr := err.Error()
return strings.Contains(errStr, "ports are not available") &&
(strings.Contains(errStr, "address already in use") ||
strings.Contains(errStr, "Only one usage of each socket address"))
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you get this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can force it by using install-runner when DD has TCP enabled (its the same that @krissetto got: #526)

const tlsCertContainerPath = "/etc/model-runner/certs"

// isPortBindingError checks if the error indicates a port is already in use
func isPortBindingError(err error) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it'd be nice to actually check whether it's another DMR instance running on that port, perhaps by checking http://localhost:12434/engines/status.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@doringeman Actually that would require to do this extra http request every single time. Because it does only affect to DD users that install vllm on WSL I prefer to not add the additional check and just add the hint in the error message.

Co-authored-by: Dorin-Andrei Geman <dorin.geman@docker.com>
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