Skip to content

Populate ImageId field in container status#12787

Merged
mikebrow merged 2 commits intocontainerd:mainfrom
avin3sh:avin3sh-fix-populate-image-id-cri-field
Jan 24, 2026
Merged

Populate ImageId field in container status#12787
mikebrow merged 2 commits intocontainerd:mainfrom
avin3sh:avin3sh-fix-populate-image-id-cri-field

Conversation

@avin3sh
Copy link
Copy Markdown
Contributor

@avin3sh avin3sh commented Jan 15, 2026

This change populates the ImageId field in the CRI ContainerStatus and ListContainers responses with the platform-specific image config digest.

For multi-architecture images, the existing ImageRef field contains the manifest list digest (same across all architectures), making it impossible to determine which actual image is running on a specific node. This causes issues, such as cri-o/cri-o#7143 (likely not applicable for containerd), but more importantly it makes it difficult for any auditing or security tool consuming the CRI API to know the specific image being used on the host.

CRI API introduced image_id field in 1.30, kubernetes/kubernetes#123508, to handle exactly these shortcomings. This PR ensures that field is correctly populate.

For a reference, CRI-O has implemented this via cri-o/cri-o#8115.

CRI Field Semantics After This Change

Field Value Purpose
ImageRef Repo digest (manifest list digest for multi-arch) Backwards compatibility, user-facing reference
ImageId Platform-specific image config digest Unique node-local image identifier

Validation

Tested on Windows Server 2022 nodes running Kubernetes v1.30.14 with multi-arch python:latest image. The following differences were observed in the output of crictl inspect <container_id>,

Before (containerd 2.2.1 without fix)

{
  "status": {
    "id": "fd119eda70ad3fecb2b2de30c8e399f04307ad1fce6db98d9f32f1cb2f985912",
    "image": {
      "image": "docker.io/library/python:latest"
    },
    "imageId": "",
    "imageRef": "docker.io/library/python@sha256:37cba1153c7a3cd4477640ce0f976f7460308f812bc29d7149532e352a97ac8b",
    "state": "CONTAINER_RUNNING"
  }
}

After (containerd 2.2.1 with this fix)

{
  "status": {
    "id": "5e49b24a6dcbb8c26e8ac709e36c8e9fb2635ea0af564a2a77ffe19e4ecf9c28",
    "image": {
      "image": "docker.io/library/python:latest"
    },
    "imageId": "sha256:901dd1e74bd316de5daf29486c05179a097ab368a527430e1230f7ec58223f69",
    "imageRef": "docker.io/library/python@sha256:37cba1153c7a3cd4477640ce0f976f7460308f812bc29d7149532e352a97ac8b",
    "state": "CONTAINER_RUNNING"
  }
}

Result:

  • imageId (sha256:901dd1e7...) = Platform-specific Windows image config digest (unique to this node's architecture)
  • imageRef (sha256:37cba115...) = Multi-arch manifest list digest (same across all platforms)

@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Jan 15, 2026
@dosubot dosubot Bot added area/cri Container Runtime Interface (CRI) kind/feature labels Jan 15, 2026
@avin3sh avin3sh force-pushed the avin3sh-fix-populate-image-id-cri-field branch 2 times, most recently from e9cc082 to 28f57bf Compare January 15, 2026 08:36
// repoDigests[0] is the manifest list digest for multi-arch images.
// This overwrites imageRef (originally the platform-specific digest)
// for backwards compatibility with existing CRI consumers.
imageRef = repoDigests[0]
Copy link
Copy Markdown
Member

@fuweid fuweid Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please double check this comment? repoDigests[0] seems image.ID.
And could you please add integration test for this change? thanks

EDITED: Test should be handled in critest side.

The CRI ImageId field was added in kubernetes/kubernetes#123508 to provide a unique image identifier on the node, separate from ImageRef which contains the manifest list digest for multi-arch images.

Previously, ImageId was not populated, leaving it empty in the CRI response. This change populates ImageId with the platform-specific image config digest (stored in container.ImageRef during container creation).

The ImageRef field continues to return the manifest list digest for backwards compatibility.

Signed-off-by: Avinesh Singh <[email protected]>
@fuweid fuweid force-pushed the avin3sh-fix-populate-image-id-cri-field branch from 791333b to 2470af5 Compare January 23, 2026 16:30
@fuweid fuweid requested a review from mikebrow January 23, 2026 16:37
@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Jan 24, 2026
@fuweid fuweid added this pull request to the merge queue Jan 24, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 24, 2026
Copy link
Copy Markdown
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikebrow mikebrow added this pull request to the merge queue Jan 24, 2026
Merged via the queue into containerd:main with commit 816a845 Jan 24, 2026
52 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jan 24, 2026
@dmcgowan dmcgowan changed the title cri: populate ImageId field in container status Populate ImageId field in container status Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants