Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when invalid command in start_exec? #249

Open
jgsch opened this issue Aug 31, 2022 · 1 comment
Open

error when invalid command in start_exec? #249

jgsch opened this issue Aug 31, 2022 · 1 comment

Comments

@jgsch
Copy link

jgsch commented Aug 31, 2022

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")

@fussybeaver
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants