Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save timoyuen/ca22eee5010ffd308742f83b64ee0ce0 to your computer and use it in GitHub Desktop.
Save timoyuen/ca22eee5010ffd308742f83b64ee0ce0 to your computer and use it in GitHub Desktop.
Backup/Save all Docker Images to a compressed file
docker images | tail -n +2 | grep -v "none" | awk '{printf("%s:%s\n", $1, $2)}' | while read IMAGE; do
echo $IMAGE
filename="${IMAGE//\//-}"
filename="${filename//:/-}.docker-image.gz"
docker save ${IMAGE} | pigz --stdout --best > $filename
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment