diff --git a/libnetwork/controller.go b/libnetwork/controller.go index ff22d79d98..4474cdc93a 100644 --- a/libnetwork/controller.go +++ b/libnetwork/controller.go @@ -320,14 +320,17 @@ func (c *controller) clusterAgentInit() { c.agentClose() c.cleanupServiceBindings("") - if err := c.ingressSandbox.Delete(); err != nil { - log.Warnf("Could not delete ingress sandbox while leaving: %v", err) - } - c.Lock() + ingressSandbox := c.ingressSandbox c.ingressSandbox = nil c.Unlock() + if ingressSandbox != nil { + if err := ingressSandbox.Delete(); err != nil { + log.Warnf("Could not delete ingress sandbox while leaving: %v", err) + } + } + n, err := c.NetworkByName("ingress") if err != nil { log.Warnf("Could not find ingress network while leaving: %v", err)