Add a script to get (compressed) size of a list of container images

This MR add a new script get_network_footprint.py to calculate the network footprint of a list of container images.
The script supports multi-platform images and provides options for JSON output, detailed layer breakdown, and platform specification.
It can process images from a file or a provided list.

It uses docker manifest inspect command to get data from registries.

The "total size" accounts for layers that can be reused multiple times.

Example output:

python ./tools/get_network_footprint.py -i rancher/rancher:v2.9.3 docker.io/grafana/loki:3.4.2
Processing images: 100%|████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:05<00:00,  2.77s/it]
Total Size: 913.2 MB
Image: rancher/rancher:v2.9.3
  Size: 877.9 MB
Image: docker.io/grafana/loki:3.4.2
  Size: 35.4 MB
python ./tools/get_network_footprint.py -f test.img -d -j
Processing images: 100%|████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:06<00:00,  1.51s/it]
{
  "images": {
    "registry.suse.com/suse/sles/15.6/cdi-operator:1.60.1-150600.3.9.1": {
      "size": 68514742,
      "layers": {
        "sha256:7531e33a5d709ae9c2f93c66e239e1deec2e1c929253ce0b84111e385fd3ac9f": 49078353,
        "sha256:f041be620d55f63f0ebfc7a3e6ff73355bca858b2e6008c2f29a8a8feafccf56": 19436389
      }
    },
    "registry.suse.com/suse/sles/15.6/cdi-controller:1.60.1-150600.3.9.1": {
      "size": 65582512,
      "layers": {
        "sha256:7531e33a5d709ae9c2f93c66e239e1deec2e1c929253ce0b84111e385fd3ac9f": 49078353,
        "sha256:aa89574f81da50aed9d1568cd33387146b123a29fb32977fa569ae637cb1d106": 16504159
      }
    },
    "registry.rancher.com/rancher/fleet-agent:v0.11.8": {
      "size": 28106444,
      "layers": {
        "sha256:a9ab94341d15b9bb5d145550fb2f24ba20c27bd94f3ad20d356d43a8ff31b35c": 5570753,
        "sha256:3d4884763281baae5492ba394b4ebd744f38e2c63ca3e3a3fdfb922bf0943481": 22535691
      }
    },
    "gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1": {
      "size": 24470471,
      "layers": {
        "sha256:79e0d8860fadaab56c716928c84875d99ff5e13787ca3fcced10b70af29bf320": 801337,
        "sha256:dc81f19f6d555fbe541d56950b4fc3c72d84fea2fcb95b418280980c894ce048": 23669134
      }
    }
  },
  "total_size": 137595816
}
Edited by Benjamin Le Diguerher

Merge request reports

Loading