blob: b8d8eafd6a622c98f3b931dca8a97292e8cbc0a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
extern crate shiplift;
extern crate tokio;
use shiplift::{errors::Error, Docker};
use std::env;
use std::fs::OpenOptions;
use std::io::Write;
use tokio::prelude::{Future, Stream};
fn main() {
let docker = Docker::new();
let id = env::args().nth(1).expect("You need to specify an image id");
let mut export_file = OpenOptions::new()
.write(true)
.create(true)
.open(format!("{}.tar", &id))
.unwrap();
let images = docker.images();
let fut = images
.get(&id)
.export()
.for_each(move |bytes| {
export_file
.write(&bytes[..])
.map(|n| println!("copied {} bytes", n))
.map_err(Error::IO)
})
.map_err(|e| eprintln!("Error: {}", e));
tokio::run(fut)
}
|