Skip to content

Instantly share code, notes, and snippets.

@bynil
Created June 22, 2018 08:32
Show Gist options
  • Save bynil/57643b0b864099b104f71299a5eb442a to your computer and use it in GitHub Desktop.
Save bynil/57643b0b864099b104f71299a5eb442a to your computer and use it in GitHub Desktop.
docker images | tail --lines=+2 | while read LINE ; do
REPO=`echo ${LINE} | awk '{print $1}'`
TAG=`echo ${LINE} | awk '{print $2}'`
ID=`echo ${LINE} | awk '{print $3}'`
# Replace '/' characters in REPO with '_'
FILENAME=${REPO//\//_}__${TAG}__${ID}.tar
IMAGE=${REPO}:${TAG}
@bynil
Copy link
Author

bynil commented Jun 22, 2018

save some images

for substr in 'your-image-tag1' 'your-image-tag2'; do
    if [ -z "${IMAGE##*$substr*}" ] ;then
      echo "Saving docker image ${REPO}:${TAG} as ${FILENAME} ..."
      docker save ${REPO}:${TAG} > ${FILENAME}
      break
    fi
  done
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment