Detect docker is not available gracefully
This commit is contained in:
parent
83b77e31f4
commit
6302dc553c
|
@ -2,6 +2,7 @@ package system
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
gonet "net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
dc "github.com/fsouza/go-dockerclient"
|
dc "github.com/fsouza/go-dockerclient"
|
||||||
|
@ -298,8 +299,11 @@ func (s *systemPS) DockerStat() ([]*DockerContainerStat, error) {
|
||||||
|
|
||||||
list, err := s.dockerClient.ListContainers(opts)
|
list, err := s.dockerClient.ListContainers(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("list err: %s\n", err)
|
if _, ok := err.(*gonet.OpError); ok {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var stats []*DockerContainerStat
|
var stats []*DockerContainerStat
|
||||||
|
|
Loading…
Reference in New Issue