Docker ListContainers will work only for the '/docker' container.
This commit is contained in:
parent
f147996e9d
commit
a748b53743
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user