From b08ee26027ce3d2246b9fbae3f3ef361c928cebd Mon Sep 17 00:00:00 2001 From: Umer Farooq Mala <57412578+umermala@users.noreply.github.com> Date: Tue, 19 Nov 2024 21:55:00 +0500 Subject: [PATCH] Update docker.go --- pkg/commands/docker.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index 28c12c23..0c11b571 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -254,10 +254,12 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta newContainer.Container = ctr // if the container is made with a name label we will use that - if name, ok := ctr.Labels["name"]; ok { + if len(ctr.Names) > 0 && ctr.Names[0] != "" { + newContainer.Name = strings.TrimLeft(ctr.Names[0], "/") + } else if name, ok := ctr.Labels["name"]; ok { newContainer.Name = name } else { - newContainer.Name = strings.TrimLeft(ctr.Names[0], "/") + newContainer.Name = "default_name" } newContainer.ServiceName = ctr.Labels["com.docker.compose.service"] newContainer.ProjectName = ctr.Labels["com.docker.compose.project"]