summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/containerexec.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/containerexec.rs b/examples/containerexec.rs
index fe542f2..b41d1ac 100644
--- a/examples/containerexec.rs
+++ b/examples/containerexec.rs
@@ -6,14 +6,17 @@ use std::env;
fn main() {
let docker = Docker::new();
let options = ExecContainerOptions::builder()
- .cmd(vec!["ls"])
+ .cmd(vec!["bash", "-c", "echo -n \"echo VAR=$VAR on stdout\"; echo -n \"echo VAR=$VAR on stderr\" >&2"])
.env(vec!["VAR=value"])
+ .attach_stdout(true)
+ .attach_stderr(true)
.build();
if let Some(id) = env::args().nth(1) {
- match docker.containers()
- .get(&id)
- .exec(&options) {
- Ok(res) => println!("Success: {:?}", res),
+ match docker.containers().get(&id).exec(&options) {
+ Ok(res) => {
+ println!("Stdout: {}", res.stdout);
+ println!("Stderr: {}", res.stderr);
+ }
Err(err) => println!("An error occured: {:?}", err),
}
}