mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: Fix restart for Hyper-V containers
Signed-off-by: Andrey Kolomentsev <andrey.kolomentsev@docker.com>
This commit is contained in:
parent
6800954050
commit
5afe2705ac
1 changed files with 16 additions and 3 deletions
|
@ -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,12 +35,24 @@ 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
|
||||
// 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() {
|
||||
// set AutoRemove flag to false before stop so the container won't be
|
||||
|
|
Loading…
Reference in a new issue