#!/usr/bin/env bash

set -e

if [ "$#" -ne 1 ]; then
  echo "Useage: ./$0 image_name:tag"
  exit 1
fi

image=$1
tar_file=$(basename "${image}" | sed 's/:/-/g')

# 拉取镜像
docker pull ${image}

# 导出镜像为 tar 文件
docker save -o ${tar_file}.tar ${image}

# 删除本地镜像
docker rmi ${image}

