You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
shell-project/os/get-docker-image.sh

35 lines
908 B

#!/bin/bash
TAG_PREFIX=
save(){
if [ ! -d "./images" ]; then
mkdir images
fi
cd images
docker images --format "{{.ID}} {{.Repository}}:{{.Tag}} {{.Size}}" |grep $TAG_PREFIX > images_pull.txt
while read line
do
image_id=`echo $line | awk '{print $1}'`
image_repository=`echo $line | awk '{print $2}'`
image_size=`echo $line | awk '{print $3}'`
docker save -o $image_id.tar $image_repository && \
echo "Image $image_repository saved, size $image_size"
done < images_pull.txt
}
load(){
cd images
while read line
do
image_id=`echo $line | awk '{print $1}'`
image_repository=`echo $line | awk '{print $2}'`
docker load -i $image_id.tar && \
echo "Image $image_repository loaded"
done < images_pull.txt
}
if [ -z "$1" ]; then
echo "Usage: image_operation.sh [save|load]"
fi
eval $1