Reputation: 101
I would like to export an image to a tar file, and I'm looking at the Docker save command. I can't seem to find it in the remote API though.
I see other commands in the remote API that supports tar streams in both the request and the response, so it seems like it should be possible.
Is this not supported, or am I missing something?
Upvotes: 1
Views: 1338
Reputation: 45313
If you know Ruby, you can try the gem docker-api:
# Export a single Docker Image to a file
# Docker command for reference: docker save <IMAGE.ID> my_export.tar
image.save('my_export.tar')
# => Docker::Image { :id => 66b712aef, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
You can also use it to create any image from a tar file:
# Create an image from a tar file.
# Docker command for reference: docker build - < docker_image.tar
Docker::Image.build_from_tar(File.open('docker_image.tar', 'r'))
# => Docker::Image { :id => 1266dc19e, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
Refer to:
Upvotes: 2