summaryrefslogtreecommitdiffstats
path: root/examples/export.rs
blob: b12e2f803f24e47682cf0c04be7d46bbbe8f77f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
extern crate shiplift;

use shiplift::Docker;
use std::env;
use std::fs::OpenOptions;
use std::io::copy;

fn main() {
    let docker = Docker::new();
    if let Some(id) = env::args().nth(1) {
        let mut export = OpenOptions::new()
            .write(true)
            .create(true)
            .open(format!("{}.tgz", &id))
            .unwrap();
        let images = docker.images();
        let mut exported = images.get(&id).export().unwrap();
        println!("copying");
        copy(&mut exported, &mut export).unwrap();
        println!("copied");
    }
}