summaryrefslogtreecommitdiffstats
path: root/examples/volumecreate.rs
blob: 83f504588fb4e238d6895bc898f91e71ef98d97e (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
use shiplift::{builder::VolumeCreateOptions, Docker};
use std::{collections::HashMap, env};
use tokio::prelude::Future;

fn main() {
    let docker = Docker::new();
    let volumes = docker.volumes();

    let volume_name = env::args()
        .nth(1)
        .expect("You need to specify an volume name");

    let mut labels = HashMap::new();
    labels.insert("com.github.softprops", "shiplift");

    let fut = volumes
        .create(
            &VolumeCreateOptions::builder()
                .name(volume_name.as_ref())
                .labels(&labels)
                .build(),
        )
        .map(|info| println!("{:?}", info))
        .map_err(|e| eprintln!("Error: {}", e));

    tokio::run(fut);
}