github.com/moby/docker@v26.1.3+incompatible/daemon/containerd/image_changes.go (about) 1 package containerd 2 3 import ( 4 "context" 5 6 "github.com/containerd/containerd/mount" 7 "github.com/containerd/log" 8 "github.com/docker/docker/container" 9 "github.com/docker/docker/pkg/archive" 10 "github.com/docker/docker/pkg/stringid" 11 ) 12 13 func (i *ImageService) Changes(ctx context.Context, container *container.Container) ([]archive.Change, error) { 14 snapshotter := i.client.SnapshotService(container.Driver) 15 info, err := snapshotter.Stat(ctx, container.ID) 16 if err != nil { 17 return nil, err 18 } 19 20 id := stringid.GenerateRandomID() 21 parentViewKey := container.ID + "-parent-view-" + id 22 imageMounts, _ := snapshotter.View(ctx, parentViewKey, info.Parent) 23 24 defer func() { 25 if err := snapshotter.Remove(ctx, parentViewKey); err != nil { 26 log.G(ctx).WithError(err).Warn("error removing the parent view snapshot") 27 } 28 }() 29 30 var changes []archive.Change 31 err = i.PerformWithBaseFS(ctx, container, func(containerRoot string) error { 32 return mount.WithReadonlyTempMount(ctx, imageMounts, func(imageRoot string) error { 33 changes, err = archive.ChangesDirs(containerRoot, imageRoot) 34 return err 35 }) 36 }) 37 38 return changes, err 39 }