From 43db69da00e8d1ea359dec48210382b1fbc3b4be Mon Sep 17 00:00:00 2001 From: ManManavadaria Date: Thu, 27 Nov 2025 19:54:53 +0530 Subject: [PATCH] Fix panic: validate Names slice length and use containerID as container name if Names slice is empty in container summary --- pkg/commands/docker.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index 9885d305..35afef2f 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -256,7 +256,11 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta if name, ok := ctr.Labels["name"]; ok { newContainer.Name = name } else { - newContainer.Name = strings.TrimLeft(ctr.Names[0], "/") + if len(ctr.Names) > 0 { + newContainer.Name = strings.TrimLeft(ctr.Names[0], "/") + } else { + newContainer.Name = ctr.ID + } } newContainer.ServiceName = ctr.Labels["com.docker.compose.service"] newContainer.ProjectName = ctr.Labels["com.docker.compose.project"]