mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-24 16:11:04 +00: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:
parent
78edbf3d2e
commit
43db69da00
1 changed files with 5 additions and 1 deletions
|
|
@ -256,7 +256,11 @@ func (c *DockerCommand) GetContainers(existingContainers []*Container) ([]*Conta
|
||||||
if name, ok := ctr.Labels["name"]; ok {
|
if name, ok := ctr.Labels["name"]; ok {
|
||||||
newContainer.Name = name
|
newContainer.Name = name
|
||||||
} else {
|
} 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.ServiceName = ctr.Labels["com.docker.compose.service"]
|
||||||
newContainer.ProjectName = ctr.Labels["com.docker.compose.project"]
|
newContainer.ProjectName = ctr.Labels["com.docker.compose.project"]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue