-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
display layer mediaType #566
Labels
enhancement
Add a new feature
Comments
In the meantime, I used this: #!/bin/bash
# Check if image name is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <image-name>"
exit 1
fi
IMAGE=$1
# Function to get media types and sizes
get_media_info() {
local manifest=$1
local config_media=$(jq -r '.config.mediaType' <<< "$manifest")
local config_size=$(jq -r '.config.size' <<< "$manifest")
echo "Config:"
echo " mediaType: $config_media"
echo " size: $config_size bytes"
echo "Layers:"
jq -r '.layers[] | " \(.mediaType)\n size: \(.size) bytes"' <<< "$manifest"
}
# Function to clean image reference
clean_image_ref() {
local img=$1
if [[ "$img" == *@* ]]; then
echo "${img%@*}"
elif [[ "$img" == *:* ]]; then
echo "${img%:*}"
else
echo "$img"
fi
}
# Get initial manifest
MANIFEST=$(skopeo inspect --raw "docker://$IMAGE")
MEDIA_TYPE=$(jq -r '.mediaType // empty' <<< "$MANIFEST")
# Handle manifest lists/indexes
if [[ $MEDIA_TYPE == "application/vnd.docker.distribution.manifest.list.v2+json" ]] ||
[[ $MEDIA_TYPE == "application/vnd.oci.image.index.v1+json" ]]; then
echo "Found manifest list/index, searching for linux/amd64..."
DIGEST=$(jq -r '.manifests[] | select(.platform.architecture == "amd64" and .platform.os == "linux").digest' <<< "$MANIFEST")
if [ -z "$DIGEST" ]; then
echo "No linux/amd64 platform found in manifest list"
exit 1
fi
# Clean image reference and add digest
CLEAN_REF=$(clean_image_ref "$IMAGE")
NEW_REF="${CLEAN_REF}@${DIGEST}"
echo "Fetching image manifest for digest: $DIGEST"
MANIFEST=$(skopeo inspect --raw "docker://$NEW_REF")
fi
# Process the final manifest
MEDIA_TYPE=$(jq -r '.mediaType // empty' <<< "$MANIFEST")
if [[ $MEDIA_TYPE == "application/vnd.docker.distribution.manifest.v2+json" ]] ||
[[ $MEDIA_TYPE == "application/vnd.oci.image.manifest.v1+json" ]]; then
get_media_info "$MANIFEST"
else
echo "Unsupported manifest media type: $MEDIA_TYPE"
exit 1
fi > ./docker-inspect.sh nvidia/cuda:12.3.2-cudnn9-devel-ubuntu22.04
Found manifest list/index, searching for linux/amd64...
Fetching image manifest for digest: sha256:4f00d5116a3679bab6bc13318c8555d7207206de2318e77348a9a93f66e73e21
Config:
mediaType: application/vnd.docker.container.image.v1+json
size: 19684 bytes
Layers:
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 29536188 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 4622976 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 57074219 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 185 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 6886 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 1287119340 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 63930 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 1684 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 1522 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 2569340468 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 88605 bytes
application/vnd.docker.image.rootfs.diff.tar.gzip
size: 675297436 bytes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What would you like to be added:
The mediaType for a layer. on top of digest and command
Why is this needed:
Performances improvements.
Additional context:
I recently discovered that everything is faster with zstd, and I want to check the media type of all the layers of an image. And also, if possible the compression level setting.
The text was updated successfully, but these errors were encountered: