Detect docker is not available gracefully

This commit is contained in:
Evan Phoenix 2015-04-07 09:24:16 -07:00
parent 83b77e31f4
commit 6302dc553c
1 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package system
import (
"fmt"
gonet "net"
"strings"
dc "github.com/fsouza/go-dockerclient"
@ -298,10 +299,13 @@ func (s *systemPS) DockerStat() ([]*DockerContainerStat, error) {
list, err := s.dockerClient.ListContainers(opts)
if err != nil {
fmt.Printf("list err: %s\n", err)
if _, ok := err.(*gonet.OpError); ok {
return nil, nil
}
return nil, err
}
var stats []*DockerContainerStat
for _, cont := range list {