pub struct BuildahCommand {
pub program: String,
pub args: Vec<String>,
pub env: HashMap<String, String>,
}Expand description
A buildah command ready for execution
Fields§
§program: StringThe program to execute (typically “buildah”)
args: Vec<String>Command arguments
env: HashMap<String, String>Optional environment variables for the command
Implementations§
Source§impl BuildahCommand
impl BuildahCommand
Sourcepub fn args(self, args: impl IntoIterator<Item = impl Into<String>>) -> Self
pub fn args(self, args: impl IntoIterator<Item = impl Into<String>>) -> Self
Add multiple arguments
Sourcepub fn arg_opt(self, flag: &str, value: Option<impl Into<String>>) -> Self
pub fn arg_opt(self, flag: &str, value: Option<impl Into<String>>) -> Self
Add an optional argument (only added if value is Some)
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 for command execution
Sourcepub fn to_command_string(&self) -> String
pub fn to_command_string(&self) -> String
Convert to a command line string for display/logging
Sourcepub fn from_image(image: &str) -> Self
pub fn from_image(image: &str) -> Self
Create a new working container from an image
buildah from <image>
Sourcepub fn from_image_named(image: &str, name: &str) -> Self
pub fn from_image_named(image: &str, name: &str) -> Self
Create a new working container from an image with a specific name
buildah from --name <name> <image>
Sourcepub fn from_scratch() -> Self
pub fn from_scratch() -> Self
Create a scratch container
buildah from scratch
Sourcepub fn commit(container: &str, image_name: &str) -> Self
pub fn commit(container: &str, image_name: &str) -> Self
Commit a container to create an image
buildah commit <container> <image>
Sourcepub fn commit_with_opts(
container: &str,
image_name: &str,
format: Option<&str>,
squash: bool,
) -> Self
pub fn commit_with_opts( container: &str, image_name: &str, format: Option<&str>, squash: bool, ) -> Self
Commit with additional options
Sourcepub fn tag(image: &str, new_name: &str) -> Self
pub fn tag(image: &str, new_name: &str) -> Self
Tag an image with a new name
buildah tag <image> <new-name>
Sourcepub fn push_to(image: &str, destination: &str) -> Self
pub fn push_to(image: &str, destination: &str) -> Self
Push an image to a registry with options
buildah push [options] <image> [destination]
Sourcepub fn inspect_format(name: &str, format: &str) -> Self
pub fn inspect_format(name: &str, format: &str) -> Self
Inspect an image or container with format
buildah inspect --format <format> <name>
Sourcepub fn containers() -> Self
pub fn containers() -> Self
List containers
buildah containers
Sourcepub fn run_shell(container: &str, command: &str) -> Self
pub fn run_shell(container: &str, command: &str) -> Self
Run a command in the container (shell form)
buildah run <container> -- /bin/sh -c "<command>"
Sourcepub fn run_exec(container: &str, args: &[String]) -> Self
pub fn run_exec(container: &str, args: &[String]) -> Self
Run a command in the container (exec form)
buildah run <container> -- <args...>
Sourcepub fn run(container: &str, command: &ShellOrExec) -> Self
pub fn run(container: &str, command: &ShellOrExec) -> Self
Run a command based on ShellOrExec
Sourcepub fn run_with_mounts(container: &str, run: &RunInstruction) -> Self
pub fn run_with_mounts(container: &str, run: &RunInstruction) -> Self
Run a command with mount specifications from a RunInstruction.
Buildah requires --mount arguments to appear BEFORE the container ID:
buildah run [--mount=...] <container> -- <command>
This method properly orders the arguments to ensure mounts are applied.
Sourcepub fn copy(container: &str, sources: &[String], dest: &str) -> Self
pub fn copy(container: &str, sources: &[String], dest: &str) -> Self
Copy files into the container
buildah copy <container> <src...> <dest>
Sourcepub fn copy_from(
container: &str,
from: &str,
sources: &[String],
dest: &str,
) -> Self
pub fn copy_from( container: &str, from: &str, sources: &[String], dest: &str, ) -> Self
Copy files from another container/image
buildah copy --from=<source> <container> <src...> <dest>
Sourcepub fn copy_instruction(container: &str, copy: &CopyInstruction) -> Self
pub fn copy_instruction(container: &str, copy: &CopyInstruction) -> Self
Copy with all options from CopyInstruction
Sourcepub fn add(container: &str, sources: &[String], dest: &str) -> Self
pub fn add(container: &str, sources: &[String], dest: &str) -> Self
Add files (like copy but with URL support and extraction)
Sourcepub fn add_instruction(container: &str, add: &AddInstruction) -> Self
pub fn add_instruction(container: &str, add: &AddInstruction) -> Self
Add with all options from AddInstruction
Sourcepub fn config_env(container: &str, key: &str, value: &str) -> Self
pub fn config_env(container: &str, key: &str, value: &str) -> Self
Set an environment variable
buildah config --env KEY=VALUE <container>
Sourcepub fn config_envs(container: &str, env: &EnvInstruction) -> Vec<Self>
pub fn config_envs(container: &str, env: &EnvInstruction) -> Vec<Self>
Set multiple environment variables
Sourcepub fn config_workdir(container: &str, dir: &str) -> Self
pub fn config_workdir(container: &str, dir: &str) -> Self
Set the working directory
buildah config --workingdir <dir> <container>
Sourcepub fn config_expose(container: &str, expose: &ExposeInstruction) -> Self
pub fn config_expose(container: &str, expose: &ExposeInstruction) -> Self
Expose a port
buildah config --port <port>/<proto> <container>
Sourcepub fn config_entrypoint_shell(container: &str, command: &str) -> Self
pub fn config_entrypoint_shell(container: &str, command: &str) -> Self
Set the entrypoint (shell form)
buildah config --entrypoint '<command>' <container>
Sourcepub fn config_entrypoint_exec(container: &str, args: &[String]) -> Self
pub fn config_entrypoint_exec(container: &str, args: &[String]) -> Self
Set the entrypoint (exec form)
buildah config --entrypoint '["exe", "arg1"]' <container>
Sourcepub fn config_entrypoint(container: &str, command: &ShellOrExec) -> Self
pub fn config_entrypoint(container: &str, command: &ShellOrExec) -> Self
Set the entrypoint based on ShellOrExec
Sourcepub fn config_cmd_shell(container: &str, command: &str) -> Self
pub fn config_cmd_shell(container: &str, command: &str) -> Self
Set the default command (shell form)
Sourcepub fn config_cmd_exec(container: &str, args: &[String]) -> Self
pub fn config_cmd_exec(container: &str, args: &[String]) -> Self
Set the default command (exec form)
Sourcepub fn config_cmd(container: &str, command: &ShellOrExec) -> Self
pub fn config_cmd(container: &str, command: &ShellOrExec) -> Self
Set the default command based on ShellOrExec
Sourcepub fn config_user(container: &str, user: &str) -> Self
pub fn config_user(container: &str, user: &str) -> Self
Set the user
buildah config --user <user> <container>
Sourcepub fn config_label(container: &str, key: &str, value: &str) -> Self
pub fn config_label(container: &str, key: &str, value: &str) -> Self
Set a label
buildah config --label KEY=VALUE <container>
Sourcepub fn config_labels(
container: &str,
labels: &HashMap<String, String>,
) -> Vec<Self>
pub fn config_labels( container: &str, labels: &HashMap<String, String>, ) -> Vec<Self>
Set multiple labels
Sourcepub fn config_volume(container: &str, path: &str) -> Self
pub fn config_volume(container: &str, path: &str) -> Self
Set volumes
buildah config --volume <path> <container>
Sourcepub fn config_stopsignal(container: &str, signal: &str) -> Self
pub fn config_stopsignal(container: &str, signal: &str) -> Self
Set the stop signal
buildah config --stop-signal <signal> <container>
Sourcepub fn config_shell(container: &str, shell: &[String]) -> Self
pub fn config_shell(container: &str, shell: &[String]) -> Self
Set the shell
buildah config --shell '["shell", "args"]' <container>
Sourcepub fn config_healthcheck(
container: &str,
healthcheck: &HealthcheckInstruction,
) -> Self
pub fn config_healthcheck( container: &str, healthcheck: &HealthcheckInstruction, ) -> Self
Set healthcheck
Sourcepub fn manifest_create(name: &str) -> Self
pub fn manifest_create(name: &str) -> Self
Create a new manifest list.
buildah manifest create <name>
Sourcepub fn manifest_add(list: &str, image: &str) -> Self
pub fn manifest_add(list: &str, image: &str) -> Self
Add an image to a manifest list.
buildah manifest add <list> <image>
Sourcepub fn manifest_push(list: &str, destination: &str) -> Self
pub fn manifest_push(list: &str, destination: &str) -> Self
Push a manifest list and all referenced images.
buildah manifest push --all <list> <destination>
Sourcepub fn manifest_rm(list: &str) -> Self
pub fn manifest_rm(list: &str) -> Self
Remove a manifest list.
buildah manifest rm <list>
Sourcepub fn from_instruction(container: &str, instruction: &Instruction) -> Vec<Self>
pub fn from_instruction(container: &str, instruction: &Instruction) -> Vec<Self>
Convert a Dockerfile instruction to buildah command(s)
Some instructions map to multiple buildah commands (e.g., multiple ENV vars)
Trait Implementations§
Source§impl Clone for BuildahCommand
impl Clone for BuildahCommand
Source§fn clone(&self) -> BuildahCommand
fn clone(&self) -> BuildahCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BuildahCommand
impl RefUnwindSafe for BuildahCommand
impl Send for BuildahCommand
impl Sync for BuildahCommand
impl Unpin for BuildahCommand
impl UnsafeUnpin for BuildahCommand
impl UnwindSafe for BuildahCommand
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more