2018-02-05 21:05:59 +00:00
|
|
|
package daemon // import "github.com/docker/docker/daemon"
|
2015-05-02 01:03:35 +00:00
|
|
|
|
2016-07-20 23:11:28 +00:00
|
|
|
import (
|
2016-10-27 22:52:32 +00:00
|
|
|
"errors"
|
2016-07-20 23:11:28 +00:00
|
|
|
"time"
|
|
|
|
|
2022-08-10 13:22:32 +00:00
|
|
|
"github.com/docker/docker/errdefs"
|
2016-07-20 23:11:28 +00:00
|
|
|
"github.com/docker/docker/pkg/archive"
|
|
|
|
)
|
2015-05-02 01:03:35 +00:00
|
|
|
|
|
|
|
// ContainerChanges returns a list of container fs changes
|
2015-09-29 17:51:40 +00:00
|
|
|
func (daemon *Daemon) ContainerChanges(name string) ([]archive.Change, error) {
|
2016-07-20 23:11:28 +00:00
|
|
|
start := time.Now()
|
2015-12-11 17:39:28 +00:00
|
|
|
container, err := daemon.GetContainer(name)
|
2015-05-02 01:03:35 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-10-13 00:29:21 +00:00
|
|
|
if isWindows && container.IsRunning() {
|
2016-10-27 22:52:32 +00:00
|
|
|
return nil, errors.New("Windows does not support diff of a running container")
|
|
|
|
}
|
|
|
|
|
2022-08-10 13:22:32 +00:00
|
|
|
if daemon.UsesSnapshotter() {
|
|
|
|
return nil, errdefs.NotImplemented(errors.New("not implemented"))
|
|
|
|
}
|
2015-11-03 01:14:09 +00:00
|
|
|
container.Lock()
|
|
|
|
defer container.Unlock()
|
2018-02-07 23:25:50 +00:00
|
|
|
if container.RWLayer == nil {
|
|
|
|
return nil, errors.New("RWLayer of container " + name + " is unexpectedly nil")
|
|
|
|
}
|
2016-07-20 23:11:28 +00:00
|
|
|
c, err := container.RWLayer.Changes()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
containerActions.WithValues("changes").UpdateSince(start)
|
|
|
|
return c, nil
|
2015-05-02 01:03:35 +00:00
|
|
|
}
|