Skip to content

Instantly share code, notes, and snippets.

@icyleaf
Last active August 1, 2016 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icyleaf/401065674c4d692f4bf4a66101d2f259 to your computer and use it in GitHub Desktop.
Save icyleaf/401065674c4d692f4bf4a66101d2f259 to your computer and use it in GitHub Desktop.
Save all docker images to disk & Load archive file to docker.
for file in $(ls *.tar); do
echo "load $file"
docker load -i $file
done
#!/usr/bin/env ruby
images = `docker images|grep -v REPOSITORY`.split("\n")
images.each do |image|
name, version, _id, _date, _size = image.gsub(/\s+/m, ' ').strip.split(' ')
filename = "#{name.tr('/', '_')}_#{version}.tar"
command = "docker save #{name}:#{version} -o #{filename}"
puts command
system(command)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment