From 1910e5ecc325c99bcb50cf8142ebd641456958d6 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 25 Feb 2018 14:03:20 +0000 Subject: [PATCH] Don't map IPs for containers that are not running For instance Kubernetes may have a record of a dead and restarted container in a pod, so both the dead and the live one will map to the same IP address and we would remove that address as ambiguous. --- render/container.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/render/container.go b/render/container.go index 6c5ba07d7..8633008bf 100644 --- a/render/container.go +++ b/render/container.go @@ -208,7 +208,11 @@ func MapContainer2IP(rpt report.Report, m report.Node) []string { // we cannot use its IP to attribute connections // (they could come from any other process on the host or DNAT-ed IPs) _, isInHostNetwork := m.Latest.Lookup(docker.IsInHostNetwork) - if doesntMakeConnections || isInHostNetwork { + // mapping IPs for containers that are not running can confuse the display + state, stateFound := m.Latest.Lookup(docker.ContainerState) + notRunning := stateFound && state != docker.StateRunning + + if doesntMakeConnections || isInHostNetwork || notRunning { return nil }