docker: refactor container related code

This commit is contained in:
yusing
2025-03-08 07:10:53 +08:00
parent 1739afae24
commit 1078731f2d
3 changed files with 15 additions and 14 deletions

View File

@@ -61,7 +61,13 @@ func (p *DockerProvider) NewWatcher() watcher.Watcher {
}
func (p *DockerProvider) loadRoutesImpl() (route.Routes, gperr.Error) {
containers, err := docker.ListContainers(p.dockerHost)
dockerClient, err := docker.NewClient(p.dockerHost)
if err != nil {
return nil, gperr.Wrap(err)
}
defer dockerClient.Close()
containers, err := dockerClient.ListContainers()
if err != nil {
return nil, gperr.Wrap(err)
}