From 0ba50819ba83c37c39b5c8ae924a888a7722ac6a Mon Sep 17 00:00:00 2001 From: John Howard Date: Wed, 9 Aug 2017 09:00:05 -0700 Subject: [PATCH] LCOW: Force to be Hyper-V Isolation Signed-off-by: John Howard --- daemon/create_windows.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/daemon/create_windows.go b/daemon/create_windows.go index bbf0dbe7b9..c63bfff17d 100644 --- a/daemon/create_windows.go +++ b/daemon/create_windows.go @@ -2,6 +2,7 @@ package daemon import ( "fmt" + "runtime" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/container" @@ -11,9 +12,19 @@ import ( // createContainerPlatformSpecificSettings performs platform specific container create functionality func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error { - // Make sure the host config has the default daemon isolation if not specified by caller. - if containertypes.Isolation.IsDefault(containertypes.Isolation(hostConfig.Isolation)) { - hostConfig.Isolation = daemon.defaultIsolation + + if container.Platform == runtime.GOOS { + // Make sure the host config has the default daemon isolation if not specified by caller. + if containertypes.Isolation.IsDefault(containertypes.Isolation(hostConfig.Isolation)) { + hostConfig.Isolation = daemon.defaultIsolation + } + } else { + // LCOW must be a Hyper-V container as you can't run a shared kernel when one + // is a Windows kernel, the other is a Linux kernel. + if containertypes.Isolation.IsProcess(containertypes.Isolation(hostConfig.Isolation)) { + return fmt.Errorf("process isolation is invalid for Linux containers on Windows") + } + hostConfig.Isolation = "hyperv" } for spec := range config.Volumes {