Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
docker_driver.sh
#!/bin/bash
repo=[SITE]/[USERNAME]/[REPO]
# example: fffonion/233
# index.hahah.io/fffonion/233
# upload a file
# ./docker_driver.sh YOUR_FILE
# copy the md5
# grab a file
# ./docker_driver.sh MD5
# the file will be downloaded into current directory
if [ -e "$1" ] ; then
md5=`md5sum $1|cut -d " " -f 1`
echo MD5 is $md5
tar -c $1 | docker import - $repo:$md5 > /dev/null
docker push $repo:$md5
docker rmi $repo:$md5 > /dev/null
else
docker pull $repo:$1
pushd /tmp
docker save $repo:$1|tar -x > /dev/null
docker rmi $repo:$1 > /dev/null
ls|grep -oP ".{64}\.json"|xargs rm
d=`ls|grep -oP ".{64}\$"`
popd
tar xf /tmp/$d/layer.tar
rm -rf /tmp/$d
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment