Docker ListContainers will work only for the '/docker' container.

This commit is contained in:
Vishnu Kannan 2014-07-22 18:55:19 +00:00
parent f147996e9d
commit a748b53743
2 changed files with 5 additions and 7 deletions

View File

@ -67,11 +67,11 @@ func (self *dockerFactory) CanHandle(name string) bool {
}
} else if name == "/" {
return false
} else if !strings.HasPrefix(name, "/docker") {
return false
} else if name == "/docker" {
// We need the docker driver to handle /docker. Otherwise the aggregation at the API level will break.
return true
} else if !strings.HasPrefix(name, "/docker/") {
return false
}
// Check if the container is known to docker and it is active.
_, id, err := splitName(name)

View File

@ -86,7 +86,6 @@ func (self *dockerContainerHandler) ContainerReference() (info.ContainerReferenc
}
func (self *dockerContainerHandler) isDockerRoot() bool {
// TODO(dengnan): Should we consider other cases?
return self.name == "/docker"
}
@ -240,6 +239,9 @@ func (self *dockerContainerHandler) GetStats() (stats *info.ContainerStats, err
}
func (self *dockerContainerHandler) ListContainers(listType container.ListType) ([]info.ContainerReference, error) {
if self.name != "/docker" {
return []info.ContainerReference{}, nil
}
opt := docker.ListContainersOptions{
All: true,
}
@ -249,10 +251,6 @@ func (self *dockerContainerHandler) ListContainers(listType container.ListType)
}
ret := make([]info.ContainerReference, 0, len(containers)+1)
for _, c := range containers {
if c.ID == self.ID {
// Skip self.
continue
}
if !strings.HasPrefix(c.Status, "Up ") {
continue
}