Merge pull request #107 from vmarmol/full-names

Added parent prefix to all Docker container and aliases.
This commit is contained in:
Vish Kannan 2014-07-23 16:05:25 -07:00
commit 6213f8b0c3

View File

@ -21,6 +21,7 @@ import (
"math"
"os"
"path"
"path/filepath"
"strings"
"github.com/docker/libcontainer"
@ -215,16 +216,22 @@ func (self *dockerContainerHandler) ListContainers(listType container.ListType)
if err != nil {
return nil, err
}
// On non-systemd systems Docker containers are under /docker.
containerPrefix := "/docker"
if self.useSystemd {
containerPrefix = "/system.slice"
}
ret := make([]info.ContainerReference, 0, len(containers)+1)
for _, c := range containers {
if !strings.HasPrefix(c.Status, "Up ") {
continue
}
path := fmt.Sprintf("/docker/%v", c.ID)
aliases := c.Names
ref := info.ContainerReference{
Name: path,
Aliases: aliases,
Name: filepath.Join(containerPrefix, c.ID),
Aliases: c.Names,
}
ret = append(ret, ref)
}