summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakolomentsev <andrey.kolomentsev@gmail.com>2019-02-11 16:24:09 -0800
committerJohn Howard <jhoward@microsoft.com>2019-02-22 10:37:39 -0800
commit5afe2705ace6960f3959edf23f660fb4fd00298e (patch)
treef064374b0f86733e1228a8bad65e77a6a687c419
parent680095405094e61218bdfaa8d53c1f70e00f5113 (diff)
downloaddocker-5afe2705ace6960f3959edf23f660fb4fd00298e.tar.gz
Windows: Fix restart for Hyper-V containers
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
-rw-r--r--daemon/restart.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/daemon/restart.go b/daemon/restart.go
index 0f06dea267..16efaa9c1d 100644
--- a/daemon/restart.go
+++ b/daemon/restart.go
@@ -3,6 +3,7 @@ package daemon // import "github.com/docker/docker/daemon"
import (
"fmt"
+ containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/container"
"github.com/sirupsen/logrus"
)
@@ -34,11 +35,23 @@ func (daemon *Daemon) ContainerRestart(name string, seconds *int) error {
// gracefully stop, before forcefully terminating the container. If
// given a negative duration, wait forever for a graceful stop.
func (daemon *Daemon) containerRestart(container *container.Container, seconds int) error {
+
+ // Determine isolation. If not specified in the hostconfig, use daemon default.
+ actualIsolation := container.HostConfig.Isolation
+ if containertypes.Isolation.IsDefault(actualIsolation) {
+ actualIsolation = daemon.defaultIsolation
+ }
+
// Avoid unnecessarily unmounting and then directly mounting
// the container when the container stops and then starts
- // again
- if err := daemon.Mount(container); err == nil {
- defer daemon.Unmount(container)
+ // again. We do not do this for Hyper-V isolated containers
+ // (implying also on Windows) as the HCS must have exclusive
+ // access to mount the containers filesystem inside the utility
+ // VM.
+ if !containertypes.Isolation.IsHyperV(actualIsolation) {
+ if err := daemon.Mount(container); err == nil {
+ defer daemon.Unmount(container)
+ }
}
if container.IsRunning() {