Created
May 17, 2024 10:04
-
-
Save ulexxander/061e3f6753f8c2b45c6e4ca1312e2318 to your computer and use it in GitHub Desktop.
Simple shell script to diff Docker image layers, see which layers was changed between two images.
This file contains 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/sh | |
# Usage: | |
# docker-layers-diff image-1 image-2 | |
set -e | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "Missing 1 / 2 args" | |
exit 1 | |
fi | |
echo "Pulling images" | |
docker pull "$1" -q | |
docker pull "$2" -q | |
docker inspect $1 | jq '.[].RootFS.Layers' > /tmp/${USER}-$$-docker-layers-diff-1.json | |
docker inspect $2 | jq '.[].RootFS.Layers' > /tmp/${USER}-$$-docker-layers-diff-2.json | |
diff -y --color /tmp/${USER}-$$-docker-layers-diff-1.json /tmp/${USER}-$$-docker-layers-diff-2.json | |
rm -f /tmp/${USER}-$$-docker-layers-diff-1.json /tmp/${USER}-$$-docker-layers-diff-2.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment