From f1087c5fcf070f151601f643418f3963facfea84 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Mon, 29 Sep 2014 17:10:15 -0700 Subject: [PATCH] Daemon: Restore network settings at startup. Signed-off-by: Andrea Luzzardi --- daemon/daemon.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/daemon/daemon.go b/daemon/daemon.go index a3c307ddad..98457ef1a4 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -367,6 +367,16 @@ func (daemon *Daemon) restore() error { registeredContainers = append(registeredContainers, container) } + // Restore networking of registered containers. + // This must be performed prior to any IP allocation, otherwise we might + // end up giving away an already allocated address. + for _, container := range registeredContainers { + if err := container.RestoreNetwork(); err != nil { + log.Errorf("Failed to restore network for %v: %v", container.Name, err) + continue + } + } + // check the restart policy on the containers and restart any container with // the restart policy of "always" if daemon.config.AutoRestart {