forked from mcuadros/ofelia
-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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)
- Issue: RemoveEventListener cause connection leak fsouza/go-dockerclient#911
- Status: Open since April 2022
- Impact:
RemoveEventListenerdoesn't properly stop internal goroutines, causing "send on closed channel" panics and connection leaks - Our workaround: Added panic recovery and cleanup delays
2. Mock Server Missing Events API (Issue #1157)
- Issue: testing.NewServer doesn't implement /events endpoint fsouza/go-dockerclient#1157 (just filed)
- Impact:
testing.NewServerdoesn't implement/eventsendpoint, causing tests to hang - Our workaround: Added polling fallback alongside event listening
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
- Official Docker SDK: https://pkg.go.dev/github.com/docker/docker/client
- go-dockerclient issue #911: RemoveEventListener cause connection leak fsouza/go-dockerclient#911
- go-dockerclient issue #1157: testing.NewServer doesn't implement /events endpoint fsouza/go-dockerclient#1157
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request