From 2a40dc00e6aeb611db8095dc8646e5132fea356b Mon Sep 17 00:00:00 2001 From: Andy Caldwell Date: Wed, 13 Feb 2019 05:12:42 +0000 Subject: Copy from container (#150) * Add 'copy_from' function to 'Container' * Run clippy * Update deps --- examples/containercopyfrom.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/containercopyfrom.rs (limited to 'examples') diff --git a/examples/containercopyfrom.rs b/examples/containercopyfrom.rs new file mode 100644 index 0000000..2ebeccf --- /dev/null +++ b/examples/containercopyfrom.rs @@ -0,0 +1,26 @@ +use shiplift::Docker; +use std::{env, path}; +use tokio::prelude::{Future, Stream}; + +fn main() { + let docker = Docker::new(); + let id = env::args() + .nth(1) + .expect("Usage: cargo run --example containercopyfrom -- "); + let path = env::args() + .nth(2) + .expect("Usage: cargo run --example containercopyfrom -- "); + let fut = docker + .containers() + .get(&id) + .copy_from(path::Path::new(&path)) + .collect() + .and_then(|stream| { + let tar = stream.concat(); + let mut archive = tar::Archive::new(tar.as_slice()); + archive.unpack(env::current_dir()?)?; + Ok(()) + }) + .map_err(|e| eprintln!("Error: {}", e)); + tokio::run(fut); +} -- cgit v1.2.3