Merge pull request #107 from vmarmol/full-names
Added parent prefix to all Docker container and aliases.
This commit is contained in:
commit
6213f8b0c3
@ -21,6 +21,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/libcontainer"
|
"github.com/docker/libcontainer"
|
||||||
@ -215,16 +216,22 @@ func (self *dockerContainerHandler) ListContainers(listType container.ListType)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
ret := make([]info.ContainerReference, 0, len(containers)+1)
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
if !strings.HasPrefix(c.Status, "Up ") {
|
if !strings.HasPrefix(c.Status, "Up ") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
path := fmt.Sprintf("/docker/%v", c.ID)
|
|
||||||
aliases := c.Names
|
|
||||||
ref := info.ContainerReference{
|
ref := info.ContainerReference{
|
||||||
Name: path,
|
Name: filepath.Join(containerPrefix, c.ID),
|
||||||
Aliases: aliases,
|
Aliases: c.Names,
|
||||||
}
|
}
|
||||||
ret = append(ret, ref)
|
ret = append(ret, ref)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user