pub struct CommitCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker commit command builder
Create a new image from a container’s changes.
§Example
use docker_wrapper::CommitCommand;
// Commit container changes to a new image
let image_id = CommitCommand::new("my-container")
.repository("myapp")
.tag("v2.0")
.message("Updated configuration")
.author("Developer <dev@example.com>")
.run()
.await?;
println!("Created image: {}", image_id.image_id());
Fields§
§executor: CommandExecutor
Command executor
Implementations§
Source§impl CommitCommand
impl CommitCommand
Sourcepub fn new(container: impl Into<String>) -> Self
pub fn new(container: impl Into<String>) -> Self
Create a new commit command
§Example
use docker_wrapper::CommitCommand;
let cmd = CommitCommand::new("my-container");
Sourcepub fn repository(self, repository: impl Into<String>) -> Self
pub fn repository(self, repository: impl Into<String>) -> Self
Set the repository name for the new image
§Example
use docker_wrapper::CommitCommand;
let cmd = CommitCommand::new("my-container")
.repository("myapp");
Sourcepub fn tag(self, tag: impl Into<String>) -> Self
pub fn tag(self, tag: impl Into<String>) -> Self
Set the tag for the new image
§Example
use docker_wrapper::CommitCommand;
let cmd = CommitCommand::new("my-container")
.repository("myapp")
.tag("v2.0");
Set the author
§Example
use docker_wrapper::CommitCommand;
let cmd = CommitCommand::new("my-container")
.author("John Doe <john@example.com>");
Sourcepub fn change(self, change: impl Into<String>) -> Self
pub fn change(self, change: impl Into<String>) -> Self
Apply Dockerfile instruction to the created image
§Example
use docker_wrapper::CommitCommand;
let cmd = CommitCommand::new("my-container")
.change("ENV VERSION=2.0")
.change("EXPOSE 8080")
.change("CMD [\"app\", \"--production\"]");
Sourcepub async fn run(&self) -> Result<CommitResult>
pub async fn run(&self) -> Result<CommitResult>
Execute the commit command
§Errors
Returns an error if:
- The Docker daemon is not running
- The container doesn’t exist
- The repository/tag format is invalid
§Example
use docker_wrapper::CommitCommand;
let result = CommitCommand::new("my-container")
.repository("myapp")
.tag("snapshot")
.run()
.await?;
println!("New image ID: {}", result.image_id());
Trait Implementations§
Source§impl Clone for CommitCommand
impl Clone for CommitCommand
Source§fn clone(&self) -> CommitCommand
fn clone(&self) -> CommitCommand
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 CommitCommand
impl Debug for CommitCommand
Source§impl DockerCommand for CommitCommand
impl DockerCommand for CommitCommand
Source§type Output = CommandOutput
type Output = CommandOutput
The output type this command produces
Source§fn build_command_args(&self) -> Vec<String>
fn build_command_args(&self) -> Vec<String>
Build the complete command arguments including subcommands
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 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 CommitCommand
impl RefUnwindSafe for CommitCommand
impl Send for CommitCommand
impl Sync for CommitCommand
impl Unpin for CommitCommand
impl UnwindSafe for CommitCommand
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