Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 0wnrepo/1ea98be3a386e9ee1ce94583c42ac617 to your computer and use it in GitHub Desktop.
Save 0wnrepo/1ea98be3a386e9ee1ce94583c42ac617 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