Skip to content

Instantly share code, notes, and snippets.

@kdeloach
Created January 22, 2018 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdeloach/65b0bcc28802460c107fec91c166a274 to your computer and use it in GitHub Desktop.
Save kdeloach/65b0bcc28802460c107fec91c166a274 to your computer and use it in GitHub Desktop.
Inspect intermediate Docker images
#!/bin/bash
set -eu
# Usage: ./docker_child_images.sh <image name>
image_name_or_id=$1
sha1=$(docker images -a | grep $image_name_or_id | head -n 1 | column -t | sed 's/ \+/,/g' | cut -d, -f3)
if [ ! -z "$sha1" ]; then
# echo "$sha1"
docker images -a --no-trunc | grep $sha1
fi
while [ ! -z "$sha1" ]; do
sha1=$(docker inspect $sha1 | grep Parent | cut -d'"' -f4 | cut -d":" -f2)
if [ ! -z "$sha1" ]; then
# echo "$sha1"
docker images -a --no-trunc | grep $sha1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment