adapt the import script to just give us a tarball instead

This commit is contained in:
Karanbir Singh 2014-04-04 00:20:56 +01:00
parent fb0aa8c285
commit cb53fe5ed1

24
docker/img2tar.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
#
# This script imports a raw image into Docker consumeable tarball. It takes one
# arguments: the name of the image file
usage() {
echo "usage: $(basename $0) <image>"
exit 1
}
image="$1"
if [[ -z $1 ]]; then
usage
fi
mount="$(mktemp -d --tmpdir)"
mount -o loop "$image" "$mount"
cd "$mount"
tar -cpSf - --acls --selinux --xattrs * | bzip2 > ${image}.tar.bz2
cd - >& /dev/null
umount "$mount"
rmdir "$mount"