forked from bitnami/minideb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerdiff
executable file
·46 lines (37 loc) · 1009 Bytes
/
dockerdiff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Compare two docker images, reporting what changed.
# The script will exit 1 if there are differences between the images
# other than their tags.
#
# It will also try and show what the differences are, comparing
# - the image config
# - the installed dpkg packages
# - changed file metadata
# - changed file checksums
set -e
set -u
set -o pipefail
IMAGE1=$1
IMAGE2=$2
inspect() {
docker inspect $1 | jq ".[0]|del(.RepoTags,.RepoDigests)"
}
dpkgl() {
docker run --rm $1 dpkg -l
}
lslr() {
docker run --rm $1 bash -c 'find / -xdev -not -path /proc -a -not -path /sys -print0 | sort -z | xargs -0 ls -ld'
}
md5() {
docker run --rm $1 bash -c 'find / -xdev -not -path /etc/hosts -a -not -path /etc/hostname -a -type f -print0 | sort -z | xargs -0 md5sum'
}
_diff() {
local cmd=$1
diff -u --label $IMAGE1 --label $IMAGE2 <($cmd $IMAGE1) <($cmd $IMAGE2)
}
if ! _diff inspect; then
_diff dpkgl || true
_diff lslr || true
_diff md5 || true
exit 1
fi