8000 Fix detection of docker image digest for diagnostic purposes by dominikschubert · Pull Request #10951 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Fix detection of docker image digest for diagnostic purposes #10951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions localstack-core/localstack/services/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ def print_runtime_information(in_docker: bool = False):
inspect_result = DOCKER_CLIENT.inspect_container(container_name)
container_id = inspect_result["Id"]
print("LocalStack Docker container id: %s" % container_id[:12])
image_sha = inspect_result["Image"]
print("LocalStack Docker image sha: %s" % image_sha)
image_details = DOCKER_CLIENT.inspect_image(inspect_result["Image"])
digests = image_details.get("RepoDigests") or ["Unavailable"]
print("LocalStack Docker image sha: %s" % digests[0])
except ContainerException:
print(
"LocalStack Docker container info: Failed to inspect the LocalStack docker container. "
Expand Down
4 changes: 4 additions & 0 deletions localstack-core/localstack/utils/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ def get_docker_image_details(image_name: str = None) -> Dict[str, str]:
result = DOCKER_CLIENT.inspect_image(image_name)
except ContainerException:
return {}

digests = result.get("RepoDigests")
sha256 = digests[0].rpartition(":")[2] if digests else "Unavailable"
result = {
"id": result["Id"].replace("sha256:", "")[:12],
"sha256": sha256,
"tag": (result.get("RepoTags") or ["latest"])[0].split(":")[-1],
"created": result["Created"].split(".")[0],
}
Expand Down
Loading
0