summaryrefslogtreecommitdiffstats
path: root/examples/networkconnect.rs
blob: a04db633bc72924b73f51df06527384e1e6b4e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use shiplift::{ContainerConnectionOptions, Docker};
use std::env;

#[tokio::main]
async fn main() {
    let docker = Docker::new();
    let networks = docker.networks();

    match (env::args().nth(1), env::args().nth(2)) {
        (Some(container_id), Some(network_id)) => {
            if let Err(e) = networks
                .get(&network_id)
                .connect(&ContainerConnectionOptions::builder(&container_id).build())
                .await
            {
                eprintln!("Error: {}", e)
            }
        }
        _ => eprintln!("please provide a container_id and network_id"),
    }
}