bollard
bollard copied to clipboard
error when invalid command in `start_exec`?
Following examples/exec.rs with a wrong command unknown_command
:
let docker = Docker::connect_with_socket_defaults()?;
let container_config = Config {
image: Some(IMAGE),
tty: Some(true),
..Default::default()
};
let container_id = docker
.create_container::<&str, &str>(None, container_config)
.await?
.id;
docker
.start_container::<String>(&container_id, None)
.await?;
let cmd = vec!["unknown_command"];
let exec_id = docker
.create_exec(
&container_id,
CreateExecOptions {
attach_stdout: Some(true),
attach_stderr: Some(true),
cmd: ,
..Default::default()
},
)
.await?
.id;
let results = docker.start_exec(&exec_id, None).await?;
if let StartExecResults::Attached { mut output, .. } = results {
while let Some(msg) = output.next().await {
println!("output > {:?}", msg);
}
}
The output is :
output > Ok(StdOut { message: b"OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: \"unknown_command\": executable file not found in $PATH: unknown\r\n" })
Shouldn't we have an Err
or a StdErr
somewhere? Or am I missing something?
(using bollard = "0.13"
)
The raw Docker API doesn't expose the exit code of a container through the start_exec
command, you would need to call wait_container
after the execution to check what the status code was.