diff --git a/libnetwork/store.go b/libnetwork/store.go index 65ae281fad..576110b668 100644 --- a/libnetwork/store.go +++ b/libnetwork/store.go @@ -399,11 +399,14 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi return } + networkID := n.ID() + endpointID := ep.ID() + c.Lock() - nw, ok := nmap[n.ID()] + nw, ok := nmap[networkID] if ok { - delete(nw.localEps, ep.ID()) + delete(nw.localEps, endpointID) c.Unlock() // Update the svc db about local endpoint leave right away @@ -417,9 +420,9 @@ func (c *controller) processEndpointDelete(nmap map[string]*netWatch, ep *endpoi // This is the last container going away for the network. Destroy // this network's svc db entry - delete(c.svcRecords, n.ID()) + delete(c.svcRecords, networkID) - delete(nmap, n.ID()) + delete(nmap, networkID) } } c.Unlock()