Overview
Currently we compute the size of the images being pruned independently of the size of the images being kept. This does not account for potentially shared layer & config digests between the images being pruned and the images being kept. We should consider refactoring the logic so that we check the layer & config size maps of the images being kept for any digests matching those which appear in the layer & config size maps of the images being pruned. If there are matches, those digests should be dropped from the prune size maps.
This demo serves as an example
The one image being pruned shares the same base layers as all the others, with a slight variation in one of its smaller layers. Yet the size calculation shows that pruning this image will free nearly all the space that is taken up by the images which will be kept. This is clearly wrong.
Acceptance