Windows: support docker diff

Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
John Howard 2016-10-27 15:52:32 -07:00
parent 1462ea37d0
commit 4fac603682
2 changed files with 10 additions and 5 deletions

View File

@ -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()

View File

@ -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)
}
}()