From c78d46f6ee8510641be51cf26577aa0d45ed001f Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 28 Mar 2014 07:49:53 -0400 Subject: [PATCH] added script to import raw images to docker --- docker/img2docker.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 docker/img2docker.sh diff --git a/docker/img2docker.sh b/docker/img2docker.sh new file mode 100755 index 0000000..9249915 --- /dev/null +++ b/docker/img2docker.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# This script imports a raw image into Docker. It takes two +# arguments: the name of the image file, and the tag to assign to the +# Docker image that it creates. + +usage() { + echo "usage: $(basename $0) " + exit 1 +} + +image="$1" +tag="$2" + +if [[ -z $1 || -z $2 ]]; then + usage +fi + +mount="$(mktemp -d --tmpdir)" +mount -o loop "$image" "$mount" + +cd "$mount" +tar -cpSf - --acls --selinux --xattrs * | docker import - "$tag" +cd - +umount "$mount" +rmdir "$mount"