Skip to content

Instantly share code, notes, and snippets.

@pasdam
Created August 18, 2020 14:09
Show Gist options
  • Save pasdam/0533c5b485aeb757681832c8a0a1e440 to your computer and use it in GitHub Desktop.
Save pasdam/0533c5b485aeb757681832c8a0a1e440 to your computer and use it in GitHub Desktop.
Script to export all local images to tar.gz archive, to import on a different machine
#!/usr/bin/env bash
OUT_DIR=~/Downloads/docker
mkdir -p $OUT_DIR
docker images --format "{{.Repository}}:{{.Tag}}" | while read image ; do
printf "Exporting "$image"..."
docker save $image | gzip > $OUT_DIR/"$(echo $image | sed 's/\//__/g' | sed 's/\:/_/g')".tar.gz
printf "done\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment