diff --git a/daemon/changes.go b/daemon/changes.go index 04c4e72032..fc8cd2752c 100644 --- a/daemon/changes.go +++ b/daemon/changes.go @@ -1,6 +1,8 @@ package daemon import ( + "errors" + "runtime" "time" "github.com/docker/docker/pkg/archive" @@ -14,6 +16,10 @@ func (daemon *Daemon) ContainerChanges(name string) ([]archive.Change, error) { return nil, err } + if runtime.GOOS == "windows" && container.IsRunning() { + return nil, errors.New("Windows does not support diff of a running container") + } + container.Lock() defer container.Unlock() c, err := container.RWLayer.Changes() diff --git a/daemon/graphdriver/windows/windows.go b/daemon/graphdriver/windows/windows.go index f41f2d0227..75a3d00e3f 100644 --- a/daemon/graphdriver/windows/windows.go +++ b/daemon/graphdriver/windows/windows.go @@ -366,7 +366,7 @@ func (d *Driver) Diff(id, parent string) (_ io.ReadCloser, err error) { // Changes produces a list of changes between the specified layer // and its parent layer. If parent is "", then all changes will be ADD changes. -// The layer should be mounted when calling this function +// The layer should not be mounted when calling this function. func (d *Driver) Changes(id, parent string) ([]archive.Change, error) { rID, err := d.resolveID(id) if err != nil { @@ -377,13 +377,12 @@ func (d *Driver) Changes(id, parent string) ([]archive.Change, error) { return nil, err } - // this is assuming that the layer is unmounted - if err := hcsshim.UnprepareLayer(d.info, rID); err != nil { + if err := hcsshim.ActivateLayer(d.info, rID); err != nil { return nil, err } defer func() { - if err := hcsshim.PrepareLayer(d.info, rID, parentChain); err != nil { - logrus.Warnf("Failed to Deactivate %s: %s", rID, err) + if err2 := hcsshim.DeactivateLayer(d.info, rID); err2 != nil { + logrus.Errorf("changes() failed to DeactivateLayer %s %s: %s", id, rID, err2) } }()