From 3bed793ba1f834c293e446f9c28993b14dc9ee79 Mon Sep 17 00:00:00 2001 From: Jana Radhakrishnan Date: Thu, 21 May 2015 18:57:17 +0000 Subject: [PATCH] Do not attempt releasing network when not attached to any network Sometimes container.cleanup() can be called from multiple paths for the same container during error conditions from monitor and regular startup path. So if the container network has been already released do not try to release it again. Signed-off-by: Jana Radhakrishnan (cherry picked from commit 6cdf8623d52e7e4c5b5265deb5f5b1d33f2e6e95) --- daemon/container_linux.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/container_linux.go b/daemon/container_linux.go index 8dd839eb6..39630834b 100644 --- a/daemon/container_linux.go +++ b/daemon/container_linux.go @@ -913,6 +913,12 @@ func (container *Container) ReleaseNetwork() { return } + // If the container is not attached to any network do not try + // to release network and generate spurious error messages. + if container.NetworkSettings.NetworkID == "" { + return + } + n, err := container.daemon.netController.NetworkByID(container.NetworkSettings.NetworkID) if err != nil { logrus.Errorf("error locating network id %s: %v", container.NetworkSettings.NetworkID, err)