Skip to content

Instantly share code, notes, and snippets.

@crazygit
Last active April 6, 2016 13:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crazygit/042d7eb4ee1be34dd5fd to your computer and use it in GitHub Desktop.
Save crazygit/042d7eb4ee1be34dd5fd to your computer and use it in GitHub Desktop.
Save all docker images to tar files for copy to another machine
#!/usr/bin/env bash
####################################################################
# Usage:
# Save all docker images to tar files for copy to another machine
####################################################################
images=$(docker images | awk 'NR>1 && $1 != "<none>" {printf("%s:%s\n", $1, $2)}')
for image in $images
do
cmd="docker save -o ${image//[\/|:]/_}.tar $image"
echo "$cmd"
$cmd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment