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