Skip to content

Instantly share code, notes, and snippets.

@Gvozd
Created May 8, 2020 22:49
Show Gist options
  • Save Gvozd/06aee4259cbc6127f121a541767ff9ec to your computer and use it in GitHub Desktop.
Save Gvozd/06aee4259cbc6127f121a541767ff9ec to your computer and use it in GitHub Desktop.
Inspect file changes by every step in `docker build`
#!/bin/bash
mkdir -p build.diffs;
i=0;
# put your docker build at enxt line. required `--no-cache --rm=false`
docker build --no-cache --rm=false -t docker101tutorial . |
grep -Pzo 'Step(.*)\n ---> Running .*\n' |
while read -r line && read -r line2;
do
echo $i;
step_command=$(echo $line | sed -n --expression "s/Step [[:digit:]]\+\/[[:digit:]]\+ : \(.\+\)/\1/p");
container_id=$(echo $line2 | sed -n --expression "s/---> Running in \(.\+\)/\1/p");
echo $step_command > build.diffs/${i}.diff;
docker container diff $container_id >> build.diffs/${i}.diff;
# TODO use `docker export $container_id | tar -tv` to more information about file sizes
(( i++ ));
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment