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 1/3] 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"] From a8b3b8a756b4955d0659788c00291a32d1565ad2 Mon Sep 17 00:00:00 2001 From: Umer Farooq Mala <57412578+umermala@users.noreply.github.com> Date: Tue, 19 Nov 2024 22:07:17 +0500 Subject: [PATCH 2/3] Update docker.go --- pkg/commands/docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index 0c11b571..3285fdbb 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -253,7 +253,7 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta } newContainer.Container = ctr - // if the container is made with a name label we will use that + // if the container is made with a name then use that directly if len(ctr.Names) > 0 && ctr.Names[0] != "" { newContainer.Name = strings.TrimLeft(ctr.Names[0], "/") } else if name, ok := ctr.Labels["name"]; ok { From 6eb57594a1016e978b31d5aaec08ea9c5a8952c6 Mon Sep 17 00:00:00 2001 From: Umer Farooq Mala <57412578+umermala@users.noreply.github.com> Date: Sun, 22 Dec 2024 15:41:23 +0500 Subject: [PATCH 3/3] updated default_name to unknown --- pkg/commands/docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index 3285fdbb..2de76068 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -259,7 +259,7 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta } else if name, ok := ctr.Labels["name"]; ok { newContainer.Name = name } else { - newContainer.Name = "default_name" + newContainer.Name = "Unknown" } newContainer.ServiceName = ctr.Labels["com.docker.compose.service"] newContainer.ProjectName = ctr.Labels["com.docker.compose.project"]