pub struct BuildCommand {
pub executor: CommandExecutor,
/* private fields */
}
Expand description
Docker build command builder with fluent API
Fields§
§executor: CommandExecutor
Command executor for extensibility
Implementations§
Source§impl BuildCommand
impl BuildCommand
Sourcepub fn new(context: impl Into<String>) -> Self
pub fn new(context: impl Into<String>) -> Self
Create a new build command for the specified context
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".");
Sourcepub fn add_host(self, host: impl Into<String>) -> Self
pub fn add_host(self, host: impl Into<String>) -> Self
Add a custom host-to-IP mapping
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.add_host("myhost:192.168.1.100");
Sourcepub fn build_arg(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn build_arg(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set a build-time variable
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.build_arg("VERSION", "1.0.0")
.build_arg("DEBUG", "true");
Sourcepub fn build_args_map(self, args: HashMap<String, String>) -> Self
pub fn build_args_map(self, args: HashMap<String, String>) -> Self
Set multiple build-time variables
§Examples
use docker_wrapper::BuildCommand;
use std::collections::HashMap;
let mut args = HashMap::new();
args.insert("VERSION".to_string(), "1.0.0".to_string());
args.insert("DEBUG".to_string(), "true".to_string());
let build_cmd = BuildCommand::new(".").build_args_map(args);
Sourcepub fn cache_from(self, image: impl Into<String>) -> Self
pub fn cache_from(self, image: impl Into<String>) -> Self
Add an image to consider as cache source
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cache_from("myapp:cache");
Sourcepub fn cgroup_parent(self, parent: impl Into<String>) -> Self
pub fn cgroup_parent(self, parent: impl Into<String>) -> Self
Set the parent cgroup for RUN instructions
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cgroup_parent("/docker");
Sourcepub fn compress(self) -> Self
pub fn compress(self) -> Self
Compress the build context using gzip
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".").compress();
Sourcepub fn cpu_period(self, period: i64) -> Self
pub fn cpu_period(self, period: i64) -> Self
Set CPU period limit
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cpu_period(100000);
Sourcepub fn cpu_quota(self, quota: i64) -> Self
pub fn cpu_quota(self, quota: i64) -> Self
Set CPU quota limit
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cpu_quota(50000);
Set CPU shares (relative weight)
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cpu_shares(512);
Sourcepub fn cpuset_cpus(self, cpus: impl Into<String>) -> Self
pub fn cpuset_cpus(self, cpus: impl Into<String>) -> Self
Set CPUs in which to allow execution
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cpuset_cpus("0-3");
Sourcepub fn cpuset_mems(self, mems: impl Into<String>) -> Self
pub fn cpuset_mems(self, mems: impl Into<String>) -> Self
Set MEMs in which to allow execution
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cpuset_mems("0-1");
Sourcepub fn disable_content_trust(self) -> Self
pub fn disable_content_trust(self) -> Self
Skip image verification
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.disable_content_trust();
Sourcepub fn file(self, dockerfile: impl Into<PathBuf>) -> Self
pub fn file(self, dockerfile: impl Into<PathBuf>) -> Self
Set the name/path of the Dockerfile
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.file("Dockerfile.prod");
Sourcepub fn force_rm(self) -> Self
pub fn force_rm(self) -> Self
Always remove intermediate containers
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.force_rm();
Sourcepub fn iidfile(self, file: impl Into<PathBuf>) -> Self
pub fn iidfile(self, file: impl Into<PathBuf>) -> Self
Write the image ID to a file
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.iidfile("/tmp/image_id.txt");
Sourcepub fn isolation(self, isolation: impl Into<String>) -> Self
pub fn isolation(self, isolation: impl Into<String>) -> Self
Set container isolation technology
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.isolation("hyperv");
Sourcepub fn label(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn label(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set metadata label for the image
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.label("version", "1.0.0")
.label("maintainer", "team@example.com");
Sourcepub fn labels(self, labels: HashMap<String, String>) -> Self
pub fn labels(self, labels: HashMap<String, String>) -> Self
Set multiple metadata labels
§Examples
use docker_wrapper::BuildCommand;
use std::collections::HashMap;
let mut labels = HashMap::new();
labels.insert("version".to_string(), "1.0.0".to_string());
labels.insert("env".to_string(), "production".to_string());
let build_cmd = BuildCommand::new(".").labels(labels);
Sourcepub fn memory(self, limit: impl Into<String>) -> Self
pub fn memory(self, limit: impl Into<String>) -> Self
Set memory limit
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.memory("1g");
Sourcepub fn memory_swap(self, limit: impl Into<String>) -> Self
pub fn memory_swap(self, limit: impl Into<String>) -> Self
Set memory + swap limit
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.memory_swap("2g");
Sourcepub fn network(self, mode: impl Into<String>) -> Self
pub fn network(self, mode: impl Into<String>) -> Self
Set networking mode for RUN instructions
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.network("host");
Sourcepub fn no_cache(self) -> Self
pub fn no_cache(self) -> Self
Do not use cache when building
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.no_cache();
Sourcepub fn platform(self, platform: impl Into<String>) -> Self
pub fn platform(self, platform: impl Into<String>) -> Self
Set platform for multi-platform builds
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.platform("linux/amd64");
Sourcepub fn pull(self) -> Self
pub fn pull(self) -> Self
Always attempt to pull newer base images
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.pull();
Sourcepub fn quiet(self) -> Self
pub fn quiet(self) -> Self
Suppress build output and print image ID on success
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.quiet();
Sourcepub fn no_rm(self) -> Self
pub fn no_rm(self) -> Self
Remove intermediate containers after successful build (default: true)
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.no_rm(); // Don't remove intermediate containers
Sourcepub fn security_opt(self, opt: impl Into<String>) -> Self
pub fn security_opt(self, opt: impl Into<String>) -> Self
Add a security option
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.security_opt("seccomp=unconfined");
Sourcepub fn shm_size(self, size: impl Into<String>) -> Self
pub fn shm_size(self, size: impl Into<String>) -> Self
Set size of /dev/shm
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.shm_size("128m");
Sourcepub fn tag(self, tag: impl Into<String>) -> Self
pub fn tag(self, tag: impl Into<String>) -> Self
Add a name and tag for the image
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.tag("myapp:latest")
.tag("myapp:1.0.0");
Set multiple tags for the image
§Examples
use docker_wrapper::BuildCommand;
let tags = vec!["myapp:latest".to_string(), "myapp:1.0.0".to_string()];
let build_cmd = BuildCommand::new(".").tags(tags);
Sourcepub fn target(self, stage: impl Into<String>) -> Self
pub fn target(self, stage: impl Into<String>) -> Self
Set the target build stage
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.target("production");
Sourcepub fn ulimit(self, limit: impl Into<String>) -> Self
pub fn ulimit(self, limit: impl Into<String>) -> Self
Add a ulimit option
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.ulimit("nofile=65536:65536");
Sourcepub fn allow(self, entitlement: impl Into<String>) -> Self
pub fn allow(self, entitlement: impl Into<String>) -> Self
Add an extra privileged entitlement
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.allow("network.host");
Sourcepub fn annotation(self, annotation: impl Into<String>) -> Self
pub fn annotation(self, annotation: impl Into<String>) -> Self
Add an annotation to the image
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.annotation("org.opencontainers.image.title=MyApp");
Sourcepub fn attest(self, attestation: impl Into<String>) -> Self
pub fn attest(self, attestation: impl Into<String>) -> Self
Add attestation parameters
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.attest("type=provenance,mode=max");
Sourcepub fn build_context(self, context: impl Into<String>) -> Self
pub fn build_context(self, context: impl Into<String>) -> Self
Add additional build context
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.build_context("mycontext=../path");
Sourcepub fn builder(self, builder: impl Into<String>) -> Self
pub fn builder(self, builder: impl Into<String>) -> Self
Override the configured builder
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.builder("mybuilder");
Sourcepub fn cache_to(self, destination: impl Into<String>) -> Self
pub fn cache_to(self, destination: impl Into<String>) -> Self
Add cache export destination
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.cache_to("type=registry,ref=myregistry/cache");
Sourcepub fn call(self, method: impl Into<String>) -> Self
pub fn call(self, method: impl Into<String>) -> Self
Set method for evaluating build
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.call("check");
Sourcepub fn check(self) -> Self
pub fn check(self) -> Self
Enable check mode (shorthand for “–call=check”)
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.check();
Sourcepub fn load(self) -> Self
pub fn load(self) -> Self
Enable load mode (shorthand for “–output=type=docker”)
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.load();
Sourcepub fn metadata_file(self, file: impl Into<PathBuf>) -> Self
pub fn metadata_file(self, file: impl Into<PathBuf>) -> Self
Write build result metadata to file
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.metadata_file("/tmp/metadata.json");
Sourcepub fn no_cache_filter(self, stage: impl Into<String>) -> Self
pub fn no_cache_filter(self, stage: impl Into<String>) -> Self
Do not cache specified stage
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.no_cache_filter("build-stage");
Sourcepub fn progress(self, progress_type: impl Into<String>) -> Self
pub fn progress(self, progress_type: impl Into<String>) -> Self
Set type of progress output
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.progress("plain");
Sourcepub fn provenance(self, provenance: impl Into<String>) -> Self
pub fn provenance(self, provenance: impl Into<String>) -> Self
Set provenance attestation (shorthand for “–attest=type=provenance”)
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.provenance("mode=max");
Sourcepub fn push(self) -> Self
pub fn push(self) -> Self
Enable push mode (shorthand for “–output=type=registry”)
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.push();
Sourcepub fn sbom(self, sbom: impl Into<String>) -> Self
pub fn sbom(self, sbom: impl Into<String>) -> Self
Set SBOM attestation (shorthand for “–attest=type=sbom”)
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.sbom("generator=image");
Sourcepub fn secret(self, secret: impl Into<String>) -> Self
pub fn secret(self, secret: impl Into<String>) -> Self
Add secret to expose to the build
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.secret("id=mysecret,src=/local/secret");
Sourcepub fn ssh(self, ssh: impl Into<String>) -> Self
pub fn ssh(self, ssh: impl Into<String>) -> Self
Add SSH agent socket or keys to expose
§Examples
use docker_wrapper::BuildCommand;
let build_cmd = BuildCommand::new(".")
.ssh("default");
Sourcepub fn get_executor(&self) -> &CommandExecutor
pub fn get_executor(&self) -> &CommandExecutor
Get a reference to the command executor
Sourcepub fn get_executor_mut(&mut self) -> &mut CommandExecutor
pub fn get_executor_mut(&mut self) -> &mut CommandExecutor
Get a mutable reference to the command executor
Source§impl BuildCommand
impl BuildCommand
Sourcepub async fn stream<F>(&self, handler: F) -> Result<StreamResult>
pub async fn stream<F>(&self, handler: F) -> Result<StreamResult>
Trait Implementations§
Source§impl Clone for BuildCommand
impl Clone for BuildCommand
Source§fn clone(&self) -> BuildCommand
fn clone(&self) -> BuildCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more