Skip to main content

exec_command

Function exec_command 

Source
pub async fn exec_command(
    client: &DockerClient,
    container: &str,
    cmd: Vec<&str>,
) -> Result<String, DockerError>
Expand description

Execute a command in a running container and capture output

Creates an exec instance, runs the command, and collects stdout/stderr. Returns the combined output as a String.

§Arguments

  • client - Docker client
  • container - Container name or ID
  • cmd - Command and arguments to execute

§Example

let output = exec_command(&client, "opencode-cloud", vec!["whoami"]).await?;