Skip to content

Instantly share code, notes, and snippets.

@tauffredou
Created September 28, 2015 14:48
Show Gist options
  • Select an option

  • Save tauffredou/4dd00c48193e7a055949 to your computer and use it in GitHub Desktop.

Select an option

Save tauffredou/4dd00c48193e7a055949 to your computer and use it in GitHub Desktop.
#!/bin/sh
IMAGE=$1
WORKDIR=$(mktemp -d -t docker_diff)
mkdir $WOKRDIR/output
git init $WORKDIR/output
echo "Image $IMAGE"
echo "workdir=$WORKDIR"
for layer in $(docker history -q --no-trunc $1 | tail -r );do
(
COMMAND=$(docker history --no-trunc $layer | grep $layer)
echo "Analysing $COMMAND"
docker save $layer | tar -C $WORKDIR/ -x
tar -xf $WORKDIR/$layer/layer.tar -C $WORKDIR/output
rm -rf $WORKDIR/$layer
cd $WORKDIR/output
git add .
git commit -m "$COMMAND" . || echo "Nothing to commmit"
) || exit 1
done
echo done
echo see $WORKDIR
@jlrigau
Copy link

jlrigau commented Nov 19, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment