support custom container names

This commit is contained in:
Jesse Duffield 2019-06-08 21:44:24 +10:00
parent a27b429807
commit 3bcef6d88c
2 changed files with 7 additions and 2 deletions

View file

@ -285,7 +285,7 @@ func (c *Container) GetDisplayCPUPerc() string {
// ProducingLogs tells us whether we should bother checking a container's logs
func (c *Container) ProducingLogs() bool {
return c.Container.State == "running"
return c.Container.State == "running" && !(c.Details.HostConfig.LogConfig.Type == "none")
}
// GetColor Container color

View file

@ -262,7 +262,12 @@ func (c *DockerCommand) GetContainers() ([]*Container, error) {
}
newContainer.Container = container
newContainer.Name = strings.TrimLeft(container.Names[0], "/")
// if the container is made with a name label we will use that
if name, ok := container.Labels["name"]; ok {
newContainer.Name = name
} else {
newContainer.Name = strings.TrimLeft(container.Names[0], "/")
}
newContainer.ServiceName = container.Labels["com.docker.compose.service"]
newContainer.ServiceID = container.Labels["com.docker.compose.config-hash"]
newContainer.ProjectName = container.Labels["com.docker.compose.project"]