Created
August 10, 2023 13:42
-
-
Save ericsmalling/d33b2e6a809a697e2bcff820655509c2 to your computer and use it in GitHub Desktop.
Revisions
-
ericsmalling created this gist
Aug 10, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/bin/bash # Set the IFS variable to a newline character IFS=$'\n' # Get the list of docker images images=$(docker images -a) # Loop through the list of images for image in $images; do # Skip the header line if [[ $image == *"REPOSITORY"* ]]; then printf "%s \t%s\n" "$image" "ARCHITECTURE" continue fi # Get the architecture of the image id=$(echo $image | awk '{print $3}') architecture=$(docker image inspect $id | jq -r '.[].Architecture') # Append the architecture to the end of the line, color architecure red if not same as this machine if [[ $architecture != $(uname -m) ]]; then color="$(tput setaf 1)" else color="" fi printf "%s \t%s%s\e[0m\n" "$image" "$color" "$architecture" done