Skip to content

Evaluate migration from go-dockerclient to official Docker SDK #269

@CybotTM

Description

@CybotTM

Related to mcuadros#228, mcuadros#47, mcuadros#216, mcuadros#215, mcuadros#214, mcuadros/ofelia PR mcuadros#386, PR mcuadros#396, PR mcuadros#397 (Docker SDK issues, CVEs, and memory leaks in go-dockerclient)

Summary

Consider migrating from github.com/fsouza/go-dockerclient to the official Docker SDK (github.com/docker/docker/client) to avoid ongoing compatibility issues and get better support.

Background

We've encountered several issues with go-dockerclient:

1. Event Listener Goroutine Leak (Issue #911)

2. Mock Server Missing Events API (Issue #1157)

3. Maintainer Recommendation

From the go-dockerclient README:

This package was created before Docker had an official Go SDK and is still maintained.
For new projects, using the official SDK is probably more appropriate as go-dockerclient lags behind the official SDK.

Official Docker SDK Benefits

  • Active maintenance by Docker team
  • Feature parity with Docker API
  • Better documentation
  • No goroutine leak issues in event handling
  • Official support for new Docker features

Migration Scope

Files using go-dockerclient

core/docker_operations.go
core/optimized_docker_client.go
core/container_monitor.go
core/runjob.go
core/execjob.go
core/localjob.go
core/servicejob.go
cli/daemon.go

API Surface Used

  • Container lifecycle: Create, Start, Stop, Remove, Inspect
  • Container logs: Logs
  • Event listening: AddEventListener, RemoveEventListener
  • Image operations: PullImage, InspectImage
  • Network operations: CreateNetwork, ConnectNetwork
  • Service operations (Swarm): CreateService, InspectService

Considerations

Pros

  • Better maintained
  • No known goroutine leaks
  • Official Docker support
  • Future-proof

Cons

  • Migration effort required
  • Need to update all Docker-related tests
  • Potential API differences to handle

Acceptance Criteria

  • Evaluate official SDK API compatibility
  • Create migration plan with phased approach
  • Migrate core Docker operations
  • Update container monitoring to use official events API
  • Update tests
  • Remove go-dockerclient dependency
  • Performance validation

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions