summaryrefslogtreecommitdiffstats
path: root/examples/containercreate.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/containercreate.rs')
-rw-r--r--examples/containercreate.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/examples/containercreate.rs b/examples/containercreate.rs
index 71307b8..f5baf39 100644
--- a/examples/containercreate.rs
+++ b/examples/containercreate.rs
@@ -1,15 +1,19 @@
extern crate shiplift;
+extern crate tokio;
use shiplift::{ContainerOptions, Docker};
use std::env;
+use tokio::prelude::Future;
fn main() {
let docker = Docker::new();
- let containers = docker.containers();
- if let Some(image) = env::args().nth(1) {
- let info = containers
- .create(&ContainerOptions::builder(image.as_ref()).build())
- .unwrap();
- println!("{:?}", info);
- }
+ let image = env::args()
+ .nth(1)
+ .expect("You need to specify an image name");
+ let fut = docker
+ .containers()
+ .create(&ContainerOptions::builder(image.as_ref()).build())
+ .map(|info| println!("{:?}", info))
+ .map_err(|e| eprintln!("Error: {}", e));
+ tokio::run(fut);
}