Skip to content

Instantly share code, notes, and snippets.

@bsnux
Created August 19, 2019 22:05
Show Gist options
  • Save bsnux/09be41381d589cd24460ee1c6e45a067 to your computer and use it in GitHub Desktop.
Save bsnux/09be41381d589cd24460ee1c6e45a067 to your computer and use it in GitHub Desktop.
Count docker images layers
#!/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