Skip to content

Instantly share code, notes, and snippets.

@gaga5lala
Created November 7, 2017 02:04
Show Gist options
  • Save gaga5lala/7ca518abb64a37da6d56430a126ca19d to your computer and use it in GitHub Desktop.
Save gaga5lala/7ca518abb64a37da6d56430a126ca19d to your computer and use it in GitHub Desktop.
Restore docker image tag from text file.
# 1. Backup image tags to text file.
# $ docker images --format "{{.Repository}}:{{.Tag}} {{.ID}}" > img_id.txt
#
# 2. Execute clean-docker-for-mac script
# $ bash clean-docker-for-mac.sh $(docker images --format "{{.ID}}" | xargs)
#
# source: https://gist.github.com/MrTrustor/e690ba75cefe844086f5e7da909b35ce#file-clean-docker-for-mac-sh
#
# 3. Execute this script to restore tags from text file.
#!/bin/bash
filename='img_id.txt'
exec < $filename
while IFS=' ' read -r col1 col2
do
echo 'repo:' $col1
echo 'tag': $col2
docker tag $col2 $col1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment