pub struct ExecCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker exec command builder with fluent API
Fields§
§executor: CommandExecutor
Command executor for extensibility
Implementations§
Source§impl ExecCommand
impl ExecCommand
Sourcepub fn new(container: impl Into<String>, command: Vec<String>) -> Self
pub fn new(container: impl Into<String>, command: Vec<String>) -> Self
Create a new exec command for the specified container and command
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["ls".to_string(), "-la".to_string()]);
Sourcepub fn detach(self) -> Self
pub fn detach(self) -> Self
Run in detached mode (background)
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["sleep".to_string(), "10".to_string()])
.detach();
Sourcepub fn detach_keys(self, keys: impl Into<String>) -> Self
pub fn detach_keys(self, keys: impl Into<String>) -> Self
Override the key sequence for detaching a container
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["bash".to_string()])
.detach_keys("ctrl-p,ctrl-q");
Sourcepub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add an environment variable
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["env".to_string()])
.env("DEBUG", "1")
.env("LOG_LEVEL", "info");
Sourcepub fn envs(self, vars: HashMap<String, String>) -> Self
pub fn envs(self, vars: HashMap<String, String>) -> Self
Add multiple environment variables
§Examples
use docker_wrapper::ExecCommand;
use std::collections::HashMap;
let mut env_vars = HashMap::new();
env_vars.insert("DEBUG".to_string(), "1".to_string());
env_vars.insert("LOG_LEVEL".to_string(), "info".to_string());
let exec_cmd = ExecCommand::new("my-container", vec!["env".to_string()])
.envs(env_vars);
Sourcepub fn env_file(self, file: impl Into<String>) -> Self
pub fn env_file(self, file: impl Into<String>) -> Self
Add an environment file
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["env".to_string()])
.env_file("/path/to/env.file");
Sourcepub fn interactive(self) -> Self
pub fn interactive(self) -> Self
Keep STDIN open even if not attached
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["bash".to_string()])
.interactive();
Sourcepub fn privileged(self) -> Self
pub fn privileged(self) -> Self
Give extended privileges to the command
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["mount".to_string()])
.privileged();
Sourcepub fn tty(self) -> Self
pub fn tty(self) -> Self
Allocate a pseudo-TTY
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["bash".to_string()])
.tty();
Sourcepub fn user(self, user: impl Into<String>) -> Self
pub fn user(self, user: impl Into<String>) -> Self
Set username or UID (format: “<name|uid>[:<group|gid>]”)
§Examples
use docker_wrapper::ExecCommand;
let exec_cmd = ExecCommand::new("my-container", vec!["whoami".to_string()])
.user("root");
let exec_cmd2 = ExecCommand::new("my-container", vec!["id".to_string()])
.user("1000:1000");
Trait Implementations§
Source§impl Clone for ExecCommand
impl Clone for ExecCommand
Source§fn clone(&self) -> ExecCommand
fn clone(&self) -> ExecCommand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ExecCommand
impl Debug for ExecCommand
Source§impl DockerCommand for ExecCommand
impl DockerCommand for ExecCommand
Source§type Output = ExecOutput
type Output = ExecOutput
The output type this command produces
Source§fn get_executor(&self) -> &CommandExecutor
fn get_executor(&self) -> &CommandExecutor
Get the command executor for extensibility
Source§fn get_executor_mut(&mut self) -> &mut CommandExecutor
fn get_executor_mut(&mut self) -> &mut CommandExecutor
Get mutable command executor for extensibility
Source§fn build_command_args(&self) -> Vec<String>
fn build_command_args(&self) -> Vec<String>
Build the complete command arguments including subcommands
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the command and return the typed output
Source§fn execute_command<'life0, 'async_trait>(
&'life0 self,
command_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn execute_command<'life0, 'async_trait>(
&'life0 self,
command_args: Vec<String>,
) -> Pin<Box<dyn Future<Output = Result<CommandOutput>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Helper method to execute the command with proper error handling
Source§fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self
Add a raw argument to the command (escape hatch)
Auto Trait Implementations§
impl Freeze for ExecCommand
impl RefUnwindSafe for ExecCommand
impl Send for ExecCommand
impl Sync for ExecCommand
impl Unpin for ExecCommand
impl UnwindSafe for ExecCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more