// cargo run --example imagepull_auth busybox username password server_address use futures::StreamExt; use docker_sdk::{Docker, PushOptions, RegistryAuth}; use std::env; #[tokio::main] async fn main() { env_logger::init(); let docker = Docker::new(); let img = env::args() .nth(1) .expect("You need to specify an image name"); let username = env::args().nth(2).expect("You need to specify an username"); let password = env::args().nth(3).expect("You need to specify a password"); let server_address = env::args().nth(4).expect("You need to specify server_address"); let auth = RegistryAuth::builder() .username(username) .password(password) .server_address(server_address) .build(); let mut stream = docker .images() .push(&PushOptions::builder().auth(auth).build(), img); while let Some(pull_result) = stream.next().await { match pull_result { Ok(output) => println!("{:?}", output), Err(e) => eprintln!("{}", e), } } }