From de5db2558539e45d452e5c5be13f88acba3951f6 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 17 Feb 2014 16:10:54 +0100 Subject: [PATCH] Avoid temporarily unmounting the container when restarting it Stopping the container will typicall cause it to unmount, to keep it mounted over the stop/start cycle we aquire a temporary reference to it during this time. This helps with https://github.com/dotcloud/docker/issues/4036 Docker-DCO-1.1-Signed-off-by: Alexander Larsson (github: alexlarsson) Upstream-commit: ab0f3f86c8d05aa69415e6909a88b621d5b37e81 Component: engine --- components/engine/container.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/engine/container.go b/components/engine/container.go index 3740a7fb73..f55b8c3c7b 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -1256,6 +1256,13 @@ func (container *Container) Stop(seconds int) error { } func (container *Container) Restart(seconds int) error { + // Avoid unnecessarily unmounting and then directly mounting + // the container when the container stops and then starts + // again + if err := container.Mount(); err == nil { + defer container.Unmount() + } + if err := container.Stop(seconds); err != nil { return err }