Skip to main content

BuildahCommand

Struct BuildahCommand 

Source
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: String

The program to execute (typically “buildah”)

§args: Vec<String>

Command arguments

§env: HashMap<String, String>

Optional environment variables for the command

Implementations§

Source§

impl BuildahCommand

Source

pub fn new(subcommand: &str) -> Self

Create a new buildah command

Source

pub fn arg(self, arg: impl Into<String>) -> Self

Add an argument

Source

pub fn args(self, args: impl IntoIterator<Item = impl Into<String>>) -> Self

Add multiple arguments

Source

pub fn arg_opt(self, flag: &str, value: Option<impl Into<String>>) -> Self

Add an optional argument (only added if value is Some)

Source

pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self

Add an environment variable for command execution

Source

pub fn to_command_string(&self) -> String

Convert to a command line string for display/logging

Source

pub fn from_image(image: &str) -> Self

Create a new working container from an image

buildah from <image>

Source

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>

Source

pub fn from_scratch() -> Self

Create a scratch container

buildah from scratch

Source

pub fn rm(container: &str) -> Self

Remove a working container

buildah rm <container>

Source

pub fn commit(container: &str, image_name: &str) -> Self

Commit a container to create an image

buildah commit <container> <image>

Source

pub fn commit_with_opts( container: &str, image_name: &str, format: Option<&str>, squash: bool, ) -> Self

Commit with additional options

Source

pub fn tag(image: &str, new_name: &str) -> Self

Tag an image with a new name

buildah tag <image> <new-name>

Source

pub fn rmi(image: &str) -> Self

Remove an image

buildah rmi <image>

Source

pub fn push(image: &str) -> Self

Push an image to a registry

buildah push <image>

Source

pub fn push_to(image: &str, destination: &str) -> Self

Push an image to a registry with options

buildah push [options] <image> [destination]

Source

pub fn inspect(name: &str) -> Self

Inspect an image or container

buildah inspect <name>

Source

pub fn inspect_format(name: &str, format: &str) -> Self

Inspect an image or container with format

buildah inspect --format <format> <name>

Source

pub fn images() -> Self

List images

buildah images

Source

pub fn containers() -> Self

List containers

buildah containers

Source

pub fn run_shell(container: &str, command: &str) -> Self

Run a command in the container (shell form)

buildah run <container> -- /bin/sh -c "<command>"

Source

pub fn run_exec(container: &str, args: &[String]) -> Self

Run a command in the container (exec form)

buildah run <container> -- <args...>

Source

pub fn run(container: &str, command: &ShellOrExec) -> Self

Run a command based on ShellOrExec

Source

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.

Source

pub fn copy(container: &str, sources: &[String], dest: &str) -> Self

Copy files into the container

buildah copy <container> <src...> <dest>

Source

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>

Source

pub fn copy_instruction(container: &str, copy: &CopyInstruction) -> Self

Copy with all options from CopyInstruction

Source

pub fn add(container: &str, sources: &[String], dest: &str) -> Self

Add files (like copy but with URL support and extraction)

Source

pub fn add_instruction(container: &str, add: &AddInstruction) -> Self

Add with all options from AddInstruction

Source

pub fn config_env(container: &str, key: &str, value: &str) -> Self

Set an environment variable

buildah config --env KEY=VALUE <container>

Source

pub fn config_envs(container: &str, env: &EnvInstruction) -> Vec<Self>

Set multiple environment variables

Source

pub fn config_workdir(container: &str, dir: &str) -> Self

Set the working directory

buildah config --workingdir <dir> <container>

Source

pub fn config_expose(container: &str, expose: &ExposeInstruction) -> Self

Expose a port

buildah config --port <port>/<proto> <container>

Source

pub fn config_entrypoint_shell(container: &str, command: &str) -> Self

Set the entrypoint (shell form)

buildah config --entrypoint '<command>' <container>

Source

pub fn config_entrypoint_exec(container: &str, args: &[String]) -> Self

Set the entrypoint (exec form)

buildah config --entrypoint '["exe", "arg1"]' <container>

Source

pub fn config_entrypoint(container: &str, command: &ShellOrExec) -> Self

Set the entrypoint based on ShellOrExec

Source

pub fn config_cmd_shell(container: &str, command: &str) -> Self

Set the default command (shell form)

Source

pub fn config_cmd_exec(container: &str, args: &[String]) -> Self

Set the default command (exec form)

Source

pub fn config_cmd(container: &str, command: &ShellOrExec) -> Self

Set the default command based on ShellOrExec

Source

pub fn config_user(container: &str, user: &str) -> Self

Set the user

buildah config --user <user> <container>

Source

pub fn config_label(container: &str, key: &str, value: &str) -> Self

Set a label

buildah config --label KEY=VALUE <container>

Source

pub fn config_labels( container: &str, labels: &HashMap<String, String>, ) -> Vec<Self>

Set multiple labels

Source

pub fn config_volume(container: &str, path: &str) -> Self

Set volumes

buildah config --volume <path> <container>

Source

pub fn config_stopsignal(container: &str, signal: &str) -> Self

Set the stop signal

buildah config --stop-signal <signal> <container>

Source

pub fn config_shell(container: &str, shell: &[String]) -> Self

Set the shell

buildah config --shell '["shell", "args"]' <container>

Source

pub fn config_healthcheck( container: &str, healthcheck: &HealthcheckInstruction, ) -> Self

Set healthcheck

Source

pub fn manifest_create(name: &str) -> Self

Create a new manifest list.

buildah manifest create <name>

Source

pub fn manifest_add(list: &str, image: &str) -> Self

Add an image to a manifest list.

buildah manifest add <list> <image>

Source

pub fn manifest_push(list: &str, destination: &str) -> Self

Push a manifest list and all referenced images.

buildah manifest push --all <list> <destination>

Source

pub fn manifest_rm(list: &str) -> Self

Remove a manifest list.

buildah manifest rm <list>

Source

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

Source§

fn clone(&self) -> BuildahCommand

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BuildahCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more