Skip to content

Support SHA256 digest lookup in local image cache#11585

Open
konstantinosGkilas wants to merge 1 commit intotestcontainers:mainfrom
konstantinosGkilas:feature/1406-cache-sha256-digests
Open

Support SHA256 digest lookup in local image cache#11585
konstantinosGkilas wants to merge 1 commit intotestcontainers:mainfrom
konstantinosGkilas:feature/1406-cache-sha256-digests

Conversation

@konstantinosGkilas
Copy link
Copy Markdown

@konstantinosGkilas konstantinosGkilas commented Mar 28, 2026

Summary

  • Index images by their repoDigests in addition to repoTags when populating LocalImagesCache
  • Digest-based image references (e.g. alpine@sha256:...) now resolve from cache without requiring an extra inspectImageCmd call
  • Gracefully skip unparseable digests with a debug log

Problem

LocalImagesCache.populateFromList() only indexed images by repoTags. When users referenced images by SHA256 digest, the cache lookup missed, forcing a redundant inspectImageCmd call on every run.

Changes

  • LocalImagesCache.java: populateFromList() now processes both image.getRepoTags() and image.getRepoDigests(), adding cache entries for each
  • LocalImagesCacheTest.java: New test class covering tag-only, digest-only, mixed, duplicate, and null scenarios

Note

Bare image IDs (sha256:... without a repository prefix) are not indexed because DockerImageName does not support that format. This could be addressed separately if needed.

Test plan

  • LocalImagesCacheTest — 7 unit tests covering all cache population paths
  • checkstyleMain / checkstyleTest / spotlessCheck pass
  • CI passes

Closes #1406

Index images by their repoDigests in addition to repoTags when
populating LocalImagesCache so that digest-based image references
(e.g. alpine@sha256:...) resolve from cache without requiring an
extra inspectImageCmd call.

Closes testcontainers#1406
@konstantinosGkilas konstantinosGkilas requested a review from a team as a code owner March 28, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image cache lookup should support SHA256 digests and Image IDs

1 participant