Created
October 19, 2020 07:51
-
-
Save amorenoz/9776cf139e2f112177cc522a508b5c8f to your computer and use it in GitHub Desktop.
Simple script to inspect container layers mediatypes and whether they can be pulled or not
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IMAGE="docker://cilium/startup-script" | |
print_mediatypes(){ | |
echo "Media types of manifest at $1" | |
info=$(sudo skopeo inspect --raw $1) | |
echo "Manifest MediaType $(echo $info | jq -r '.config.mediaType')" | |
echo "Layers:" | |
echo $info | jq -r '.layers[]| " Layer: \(.digest) MediaType = \(.mediaType)"' | |
} | |
for tag in $(sudo skopeo list-tags $IMAGE | jq -r '.Tags[]'); do | |
echo "" | |
echo "" | |
echo Tag: $tag | |
manifests=$(sudo skopeo inspect --raw $IMAGE:$tag | jq -r '.manifests[].digest' 2>/dev/null) | |
if [ -z "$manifests" ]; then | |
echo "plain manifest" | |
print_mediatypes $IMAGE:$tag | |
else | |
echo "Iterating over nested manifests:" | |
for manifest in $manifests; do | |
print_mediatypes $IMAGE@$manifest | |
done | |
fi | |
echo "" | |
echo -n "Can be pulled? " | |
sudo podman pull $IMAGE:$tag > /dev/null 2>&1 && echo "Yes" || echo "No" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment