Skip to content

Instantly share code, notes, and snippets.

@fffonion
Created March 6, 2016 05:28
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 fffonion/baa7a1f7707c626dac24 to your computer and use it in GitHub Desktop.
Save fffonion/baa7a1f7707c626dac24 to your computer and use it in GitHub Desktop.
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