From 510b4b9ad68549e5a21eab16d37f4676b6811530 Mon Sep 17 00:00:00 2001 From: "Dowideit, Sven (O&A, St. Lucia)" Date: Tue, 9 Jul 2019 15:52:29 +1000 Subject: [PATCH] set the service name in getContainers Signed-off-by: Dowideit, Sven (O&A, St. Lucia) --- pkg/commands/docker.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index edc3c6ff..c2e05693 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -240,16 +240,10 @@ func (c *DockerCommand) RefreshContainersAndServices() error { func (c *DockerCommand) assignContainersToServices(containers []*Container, services []*Service) { for _, service := range services { for _, container := range containers { - if !container.OneOff && container.ServiceName == service.Name { + if /*!container.OneOff &&*/ container.ServiceName == service.Name { service.Container = append(service.Container, container) continue } - if container.Container.Labels["com.docker.swarm.service.name"] == service.Name { - //Swarm service - service.Container = append(service.Container, container) - container.ServiceName = service.Name - continue - } } } } @@ -330,7 +324,15 @@ func (c *DockerCommand) GetContainers() ([]*Container, error) { newContainer.Name = strings.TrimLeft(container.Names[0], "/") } newContainer.ServiceName = container.Labels["com.docker.compose.service"] + if container.Labels["com.docker.swarm.service.name"] != "" { + newContainer.ServiceName = container.Labels["com.docker.swarm.service.name"] + } + newContainer.ProjectName = container.Labels["com.docker.compose.project"] + if container.Labels["com.docker.stack.namespace"] != "" { + newContainer.ProjectName = container.Labels["com.docker.stack.namespace"] + } + newContainer.ContainerNumber = container.Labels["com.docker.compose.container"] newContainer.OneOff = container.Labels["com.docker.compose.oneoff"] == "True"