Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
Created May 5, 2019 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hashbrowncipher/9b811bad8353a7246695a1e2bfea0e84 to your computer and use it in GitHub Desktop.
Save hashbrowncipher/9b811bad8353a7246695a1e2bfea0e84 to your computer and use it in GitHub Desktop.
generates a squashfs from a docker image
#!/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