Created
August 19, 2019 22:05
-
-
Save bsnux/09be41381d589cd24460ee1c6e45a067 to your computer and use it in GitHub Desktop.
Count docker images layers
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=$1 | |
usage () { | |
echo -n "Usage: $0 <full-image-URL> | |
Count number of layers of given Docker image | |
Options: | |
-h, --help Display this help and exit | |
" | |
exit 1 | |
} | |
if [ "$#" -lt 1 ]; then | |
usage | |
fi | |
if [[ $1 == "--help" || $1 == "-h" ]]; then | |
usage | |
fi | |
docker inspect $image | jq ".[0].RootFS.Layers" | sed '1d;$d' | wc -l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment