diff --git a/collector/imagescollector.go b/collector/imagescollector.go index 7f389b210..7672cdf65 100644 --- a/collector/imagescollector.go +++ b/collector/imagescollector.go @@ -143,14 +143,20 @@ func getAllImageNames() ([]string, error) { logrus.Warnf("Error while running docker image list : %s", err) return nil, err } - images := strings.Split(string(outputStr), "\n") + if len(outputStr) == 0 { + return []string{}, err + } cleanimages := []string{} + images := strings.Split(strings.TrimSpace(string(outputStr)), "\n") for _, image := range images { if strings.HasPrefix(image, "") || strings.HasSuffix(image, "") { logrus.Debugf("Ignore image with : %s", image) continue + } else { + cleanimages = append(cleanimages, image) } } + logrus.Debugf("clean images : %s", cleanimages) return cleanimages, err }