批量下载以及导出镜像

images_base.txt 内容如下所示:

gcr.io/spiffe-io/spire-agent:1.0.0
gcr.io/spiffe-io/spire-server:1.0.0

#!/bin/bash
# 创建文件夹
rm -rf images/*
rm -rf images.tar.gz
mkdir images

# pull、save 镜像
echo "拉取并且保存镜像"
for pull_image in $(cat images_base.txt)
do
  echo "开始拉取 $pull_image 镜像"
  version_name=`echo $pull_image | awk -F '/' '{print $3}'`
  fileName=${version_name//:/_}
  echo "压缩的文件镜像是 ${fileName}"
  docker pull $pull_image
  docker save $pull_image | gzip -c > ./images/$fileName.tar.gz
done
echo -e "保存完成\n\n"

# 打包镜像
echo "打包镜像"
tar -czvf images.tar.gz images
echo -e "打包完成"
 

你可能感兴趣的:(docker,debian,linux,bash)