summaryrefslogtreecommitdiffstats
path: root/examples/networkdisconnect.rs
blob: 78f33c65e4117f14093f984665523c1db90f1079 (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::{ContainerConnectionOptions, Docker};
use std::env;

async fn network_disconnect(
    container_id: &str,
    network_id: &str,
) {
    let docker = Docker::new();
    if let Err(e) = docker
        .networks()
        .get(network_id)
        .disconnect(&ContainerConnectionOptions::builder(container_id).build())
        .await
    {
        eprintln!("Error: {}", e)
    }
}

#[tokio::main]
async fn main() {
    match (env::args().nth(1), env::args().nth(2)) {
        (Some(container_id), Some(network_id)) => {
            network_disconnect(&container_id, &network_id).await;
        }
        _ => eprintln!("please provide a container_id and network_id"),
    }
}