Skip to content

Commit 4fac603

Browse files
author
John Howard
committed
Windows: support docker diff
Signed-off-by: John Howard <[email protected]>
1 parent 1462ea3 commit 4fac603

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

daemon/changes.go

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package daemon
22

33
import (
4+
"errors"
5+
"runtime"
46
"time"
57

68
"github.com/docker/docker/pkg/archive"
@@ -14,6 +16,10 @@ func (daemon *Daemon) ContainerChanges(name string) ([]archive.Change, error) {
1416
return nil, err
1517
}
1618

19+
if runtime.GOOS == "windows" && container.IsRunning() {
20+
return nil, errors.New("Windows does not support diff of a running container")
21+
}
22+
1723
container.Lock()
1824
defer container.Unlock()
1925
c, err := container.RWLayer.Changes()

daemon/graphdriver/windows/windows.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func (d *Driver) Diff(id, parent string) (_ io.ReadCloser, err error) {
366366

367367
// Changes produces a list of changes between the specified layer
368368
// and its parent layer. If parent is "", then all changes will be ADD changes.
369-
// The layer should be mounted when calling this function
369+
// The layer should not be mounted when calling this function.
370370
func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
371371
rID, err := d.resolveID(id)
372372
if err != nil {
@@ -377,13 +377,12 @@ func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
377377
return nil, err
378378
}
379379

380-
// this is assuming that the layer is unmounted
381-
if err := hcsshim.UnprepareLayer(d.info, rID); err != nil {
380+
if err := hcsshim.ActivateLayer(d.info, rID); err != nil {
382381
return nil, err
383382
}
384383
defer func() {
385-
if err := hcsshim.PrepareLayer(d.info, rID, parentChain); err != nil {
386-
logrus.Warnf("Failed to Deactivate %s: %s", rID, err)
384+
if err2 := hcsshim.DeactivateLayer(d.info, rID); err2 != nil {
385+
logrus.Errorf("changes() failed to DeactivateLayer %s %s: %s", id, rID, err2)
387386
}
388387
}()
389388

0 commit comments

Comments
 (0)