Created
May 5, 2019 07:53
-
-
Save hashbrowncipher/9b811bad8353a7246695a1e2bfea0e84 to your computer and use it in GitHub Desktop.
generates a squashfs from a docker image
This file contains hidden or 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
#!/usr/bin/fakeroot /bin/bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
OUTFILE=$2.squashfs | |
TMPDIR=$(mktemp -d -p .) | |
cleanup() { | |
rm -fr $TMPDIR | |
} | |
trap cleanup EXIT | |
CONTAINER=$(docker create $1) | |
docker export $CONTAINER | tar -C $TMPDIR -p -s --same-owner -xv | |
docker rm $CONTAINER | |
mksquashfs $TMPDIR $OUTFILE -info -processors 1 -noappend -comp xz -Xdict-size 100% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment