mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-08-24 10:13:39 -05:00
Fix panic: validate Names slice length and use containerID as container name if Names slice is empty in container summary
This commit is contained in:
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user