Skip to content

Commit

Permalink
add script caching images from docker-compose.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
g-pavlik committed Dec 31, 2015
1 parent 139dff9 commit 8fe37f3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions load_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

## this simple script checks if you have docker images stored as tar archives
## if so - it will load it from there, if not - it will pull and save it there
## useful for circle images caching:
## https://circleci.com/docs/docker#caching-docker-layers

cache_dir=~/cache_docker_images/
mkdir -p $cache_dir
for image in `cat docker-compose.yml | grep 'image:' | grep -o ' [^ ]*$'`; do
filename=$( echo "$image" | sed -r 's/\//_/g' )

image_path="$cache_dir""$filename"".tar"

if [[ -e $image_path ]]; then
echo "Image $image exists in $image_path, loading..."
docker load -i $image_path
else
echo "Image $image not found, pulling..."
docker pull $image
echo "saving $image > $image_path"
docker save $image > $image_path
fi

done

0 comments on commit 8fe37f3

Please sign in to comment.