Skip to content

Commit 8393c63

Browse files
committed
add sha256 prefix if missing
1 parent 98f4532 commit 8393c63

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tesseract_core/sdk/docker_client.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ class Image:
4242
@classmethod
4343
def from_dict(cls, json_dict: dict) -> "Image":
4444
"""Create an Image object from a json dictionary."""
45+
image_id = json_dict.get("Id", None)
46+
if image_id and not image_id.startswith("sha256:"):
47+
# Some container engines (e.g., Podman) do not prefix the ID with sha256:
48+
image_id = f"sha256:{image_id}"
4549
return cls(
46-
id=json_dict.get("Id", None),
47-
short_id=json_dict.get("Id", [])[:19],
50+
id=image_id,
51+
short_id=image_id[:19] if image_id else None,
4852
tags=json_dict.get("RepoTags", None),
4953
attrs=json_dict,
5054
)
@@ -306,7 +310,7 @@ def image(self) -> Image | None:
306310
image_id = self.attrs.get("ImageID", self.attrs["Image"])
307311
if image_id is None:
308312
return None
309-
return Images.get(image_id.split(":")[1])
313+
return Images.get(image_id)
310314

311315
@property
312316
def host_port(self) -> str | None:

0 commit comments

Comments
 (0)