Skip to content

[Request]: Calculate/Include Full Size in JSON Output of images. #860

@theetherGit

Description

@theetherGit

Feature or enhancement request details

Right now I'm not sure it should be a bug or request.

Currently, in json format we have descriptor details and there is no full image size in json format while in table format we have calculated full image size in size field.

  • List images with verbose flag
container image ls -v

output:
Image

  • List images with json format
container image ls --format json

output:
Image

[
  {
    "reference": "docker.io/library/alpine:latest",
    "descriptor": {
      "digest": "sha256:4b7ce07002c69e8f3d704a9c5d6fd3053be500b7f1c69fc0d80990c2ad8dd412",
      "mediaType": "application/vnd.oci.image.index.v1+json",
      "size": 9218
    }
  },
  {
    "reference": "docker.io/library/postgres:latest",
    "descriptor": {
      "digest": "sha256:41fc5342eefba6cc2ccda736aaf034bbbb7c3df0fdb81516eba1ba33f360162c",
      "mediaType": "application/vnd.oci.image.index.v1+json",
      "size": 10229
    }
  },
  {
    "reference": "ghcr.io/apple/containerization/vminit:0.8.1",
    "descriptor": {
      "mediaType": "application/vnd.oci.image.index.v1+json",
      "size": 306,
      "digest": "sha256:666991717c0d26a211b400b09ad45ac84a9f64af8a08c2c64a54884e76d98954"
    }
  },
  {
    "reference": "ghcr.io/apple/containerization/vminit:0.9.1",
    "descriptor": {
      "size": 306,
      "mediaType": "application/vnd.oci.image.index.v1+json",
      "digest": "sha256:6839bd6e230281df328571bd15929f8115303cba19737f3d888cc77a113e482d"
    }
  }
]

In json format, we get size from the descriptor instead of sum of sizes from descriptor , layers and manifest config.

Code reference for how size of image is calculated in table format: https://github.com/apple/container/blob/main/Sources/ContainerCommands/Image/ImageList.swift#L83-L84

Expected:
In json format of images we should have full image size:

{
    "reference": "ghcr.io/apple/containerization/vminit:0.9.1",
    "size": "172.5 MB"
    "descriptor": {
      "size": 306,
      "mediaType": "application/vnd.oci.image.index.v1+json",
      "digest": "sha256:6839bd6e230281df328571bd15929f8115303cba19737f3d888cc77a113e482d"
    },
  }

Docker cli do provide same size for image in table and json format.

Image

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions