Skip to content

migrate to moby modules#694

Open
thaJeztah wants to merge 1 commit intodocker:mainfrom
thaJeztah:migrate_moby
Open

migrate to moby modules#694
thaJeztah wants to merge 1 commit intodocker:mainfrom
thaJeztah:migrate_moby

Conversation

@thaJeztah
Copy link
Member

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @thaJeztah, 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 modernizes the codebase by migrating all Docker client interactions to use the github.com/moby/moby modules. This change aligns the project with the upstream Moby project's client libraries, ensuring better compatibility, maintainability, and access to the latest Docker Engine API features. The migration involved updating numerous API types, client method signatures, and dependency management, resulting in a more robust and future-proof integration with the Docker ecosystem.

Highlights

  • Moby Client Migration: Migrated all Docker client interactions from github.com/docker/docker to github.com/moby/moby modules, updating imports, API types, and client method calls across the codebase.
  • API Type Modernization: Updated various Docker API types, such as container.LogsOptions, image.PullOptions, nat.PortSet, nat.PortMap, nat.PortBinding, container.ExecOptions, container.ListOptions, volume.ListOptions, and filters.NewArgs to their equivalent client or network package types within the moby/moby module.
  • IP Address Handling: Introduced netip package for more robust IP address parsing and handling, replacing string comparisons for loopback addresses and ensuring valid IP string conversions.
  • Client Call Refactoring: Refactored Docker client method calls to use explicit options structs (e.g., client.ContainerCreateOptions, client.ContainerStartOptions, client.ExecCreateOptions, client.InfoOptions) for improved clarity and compatibility with the new Moby client.
  • Dependency Updates: Modified go.mod and go.sum to reflect the removal of direct dependencies on github.com/docker/docker and github.com/docker/go-connections, and added github.com/moby/moby/api as a direct dependency, along with updates to other indirect dependencies.

🧠 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.

Changelog
  • cmd/cli/commands/install-runner.go
    • Updated Docker API imports from github.com/docker/docker to github.com/moby/moby.
    • Modified port IP checking logic to use port.IP.IsLoopback() and port.IP.IsValid() with port.IP.String() for gateway IP.
  • cmd/cli/commands/logs.go
    • Updated Docker API imports from github.com/docker/docker to github.com/moby/moby.
    • Changed container.LogsOptions to client.ContainerLogsOptions in ContainerLogs call.
  • cmd/cli/commands/nim.go
    • Updated Docker API imports, replacing github.com/docker/docker and github.com/docker/go-connections/nat with github.com/moby/moby equivalents.
    • Introduced netip package for IP address handling.
    • Updated image.PullOptions to client.ImagePullOptions.
    • Refactored ContainerList, ContainerCreate, ContainerStart, and ContainerInspect calls to use new client options structs.
    • Migrated nat.PortSet and nat.PortMap to network.PortSet and network.PortMap respectively, using network.PortFrom and netip.MustParseAddr.
  • cmd/cli/desktop/context.go
    • Updated Docker API imports from github.com/docker/docker to github.com/moby/moby.
    • Changed clientpkg.Client to client.Client and updated client options (client.Opt) for client.New.
    • Removed clientpkg.WithAPIVersionNegotiation() as it's no longer needed with the new client.
    • Added defer dockerClient.Close() to ensure client resources are released.
    • Updated ContainerCreate call to use client.ContainerCreateOptions.
    • Modified TLS handling for Desktop contexts to explicitly state that TLS is not supported.
  • cmd/cli/desktop/progress.go
    • Updated Docker API imports from github.com/docker/docker to github.com/moby/moby.
    • Changed jsonmessage.JSONProgress to jsonstream.Progress and jsonmessage.JSONMessage to jsonstream.Message.
  • cmd/cli/pkg/gpu/gpu.go
    • Updated Docker API imports from github.com/docker/docker to github.com/moby/moby.
    • Changed dockerClient.Info(ctx) to dockerClient.Info(ctx, client.InfoOptions{}) and updated access to runtime information.
    • Refactored runtime detection into a new helper function hasRuntime to reduce code duplication.
  • cmd/cli/pkg/standalone/containers.go
    • Updated Docker API imports, replacing github.com/docker/docker and github.com/docker/go-connections/nat with github.com/moby/moby equivalents.
    • Introduced netip for IP address parsing in port binding logic.
    • Migrated filters.NewArgs to make(client.Filters).Add for container and network listing.
    • Updated CopyToContainer to use client.CopyToContainerOptions.
    • Refactored ContainerExecCreate, ContainerExecStart, ContainerExecInspect to ExecCreate, ExecStart, ExecInspect respectively, using new client options structs.
    • Updated NetworkInspect, ContainerStart, ContainerCreate, ContainerRemove, and ContainerRestart calls to use new client options structs.
    • Migrated nat.PortSet and nat.PortMap to network.PortSet and network.PortMap respectively, using network.PortFrom and netip.Addr.
  • cmd/cli/pkg/standalone/images.go
    • Updated Docker API imports from github.com/docker/docker to github.com/moby/moby.
    • Changed image.PullOptions to client.ImagePullOptions and image.RemoveOptions to client.ImageRemoveOptions.
  • cmd/cli/pkg/standalone/volumes.go
    • Updated Docker API imports from github.com/docker/docker to github.com/moby/moby.
    • Migrated filters.NewArgs to make(client.Filters).Add for volume listing and pruning.
    • Updated VolumeList, VolumeCreate, and VolumesPrune calls and their return value access to align with the new client API.
  • go.mod
    • Removed direct dependencies on github.com/docker/docker and github.com/docker/go-connections.
    • Added github.com/moby/moby/api as a direct dependency.
    • Updated versions for github.com/klauspost/compress, github.com/davecgh/go-spew, and github.com/pmezard/go-difflib.
  • go.sum
    • Updated checksums to reflect changes in go.mod dependencies.
Activity
  • The pull request was created by thaJeztah.
  • The changes primarily involve migrating Go module dependencies and updating API calls to align with the moby/moby client library.
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.

Comment on lines +348 to +354
// FIXME(thaJeztah): can we get the user-agent in some other way? (or just use a default, specific to DMR)?
// dockerClient, err := DockerClientForContext(cli, cli.CurrentContext())
// if err != nil {
// return nil, fmt.Errorf("unable to create model runner client: %w", err)
// }
// httpClient = dockerClient.HTTPClient()
// dockerClient.Close()
Copy link
Member Author

Choose a reason for hiding this comment

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

This part should probably be looked into; what user-agent do we want to use here? Could model-runner use its own?

@thaJeztah thaJeztah closed this Feb 18, 2026
@thaJeztah thaJeztah reopened this Feb 18, 2026
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

The pull request successfully migrates the Docker Model Runner CLI to use Moby modules instead of the deprecated Docker/Docker modules. This is a significant improvement for maintainability and ensures compatibility with the latest Moby API. The changes involve updating import paths, adjusting API calls to match the new Moby client signatures, and refining some logic related to container operations and progress display. The introduction of netip.Addr for IP addresses is a good step towards more robust network handling. Overall, the changes are well-executed and align with modern Go and Docker API practices.

result := &standaloneRunner{}
for _, port := range container.Ports {
if port.IP == "127.0.0.1" {
if port.IP.IsLoopback() {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using port.IP.IsLoopback() is a more robust and idiomatic way to check for loopback addresses compared to a string comparison with "127.0.0.1". This change correctly leverages the netip package's functionality.

@gemini-code-assist

This comment was marked as outdated.

@thaJeztah

This comment was marked as outdated.

@thaJeztah
Copy link
Member Author

That bot is really noisy though; mostly with "hey this code-change looks good!" comments 🫠

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 migrates the project from using the github.com/docker/docker client to the github.com/moby/moby modules. The changes are mostly straightforward API updates. However, I've found a couple of critical issues that could cause panics or prevent containers from starting correctly, along with a minor maintainability improvement. Please review the detailed comments.

@thaJeztah thaJeztah marked this pull request as ready for review February 18, 2026 16:04
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 found 1 issue, and left some high level feedback:

  • In CreateControllerContainer's createPortBindings helper, the initial HostIP is derived by parsing the port string instead of the host (and the host parameter is otherwise unused), which will silently yield an empty/zero IP and ignore non-default hosts; this should parse and use the host value instead.
  • In DetectContext for Desktop contexts, the httpClient is now left unset (the DockerClientForContext and HTTPClient wiring is commented out), so any downstream code that assumes a non-nil client may panic or behave differently; consider either wiring a concrete http.Client or making the nil case explicit and handled.
  • The new DockerClientForContext drops the previous WithAPIVersionNegotiation option when constructing the moby client, which may cause compatibility issues with older daemons; consider reintroducing equivalent version negotiation behavior if supported.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In CreateControllerContainer's createPortBindings helper, the initial HostIP is derived by parsing the port string instead of the host (and the host parameter is otherwise unused), which will silently yield an empty/zero IP and ignore non-default hosts; this should parse and use the host value instead.
- In DetectContext for Desktop contexts, the httpClient is now left unset (the DockerClientForContext and HTTPClient wiring is commented out), so any downstream code that assumes a non-nil client may panic or behave differently; consider either wiring a concrete http.Client or making the nil case explicit and handled.
- The new DockerClientForContext drops the previous WithAPIVersionNegotiation option when constructing the moby client, which may cause compatibility issues with older daemons; consider reintroducing equivalent version negotiation behavior if supported.

## Individual Comments

### Comment 1
<location> `cmd/cli/pkg/standalone/containers.go:451-456` </location>
<code_context>
 	// Helper function to create port bindings with optional bridge gateway IP
-	createPortBindings := func(port string) []nat.PortBinding {
-		portBindings := []nat.PortBinding{{HostIP: host, HostPort: port}}
+	createPortBindings := func(port string) []network.PortBinding {
+		var hostIP netip.Addr
+		if p, err := netip.ParseAddr(port); err == nil {
+			hostIP = p
+		}
+		portBindings := []network.PortBinding{{
+			HostIP:   hostIP,
+			HostPort: port,
</code_context>

<issue_to_address>
**issue (bug_risk):** Host IP parsing in `createPortBindings` is using the port string instead of the host string, so the primary binding's HostIP will never be set correctly.

Inside `createPortBindings`, `netip.ParseAddr(port)` is parsing the numeric port string (e.g., "8080"), so it will always fail and `hostIP` remains the zero value. Previously, the host IP came from the `host` variable (e.g., `127.0.0.1`), so the first `PortBinding` now gets an unset HostIP.

`host` should be parsed and used for the initial binding (e.g., parse `host` once and reuse it), and `netip.ParseAddr` should only be applied to actual IP strings (such as `bridgeGatewayIP`).
</issue_to_address>

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.

@thaJeztah thaJeztah force-pushed the migrate_moby branch 2 times, most recently from 3b4864f to ea003d2 Compare February 18, 2026 16:12
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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.

1 participant

Comments