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.
This commit is contained in:
Bryan Boreham
2018-02-25 14:03:20 +00:00
parent c39254f63c
commit 1910e5ecc3

View File

@@ -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
}