pub struct ContainerBuilder<'a> { /* private fields */ }Expand description
Builder for creating containers with a fluent API.
Implementations§
Source§impl<'a> ContainerBuilder<'a>
impl<'a> ContainerBuilder<'a>
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.
§Example
client.containers()
.create("nginx:latest")
.env("ENV", "production")
.env("DEBUG", "false")
.build()
.await?;Sourcepub fn volume(
self,
host_path: impl Into<String>,
container_path: impl Into<String>,
) -> Self
pub fn volume( self, host_path: impl Into<String>, container_path: impl Into<String>, ) -> Self
Sourcepub fn cmd(self, cmd: Vec<impl Into<String>>) -> Self
pub fn cmd(self, cmd: Vec<impl Into<String>>) -> Self
Set the command to run in the container.
§Example
client.containers()
.create("alpine:latest")
.cmd(vec!["echo", "hello"])
.build()
.await?;Sourcepub fn entrypoint(self, entrypoint: Vec<impl Into<String>>) -> Self
pub fn entrypoint(self, entrypoint: Vec<impl Into<String>>) -> Self
Set the entrypoint.
Sourcepub fn working_dir(self, dir: impl Into<String>) -> Self
pub fn working_dir(self, dir: impl Into<String>) -> Self
Set the working directory.
Sourcepub fn restart_always(self) -> Self
pub fn restart_always(self) -> Self
Set the restart policy to “always”.
Sourcepub fn restart_unless_stopped(self) -> Self
pub fn restart_unless_stopped(self) -> Self
Set the restart policy to “unless-stopped”.
Sourcepub fn restart_on_failure(self, max_retries: Option<i64>) -> Self
pub fn restart_on_failure(self, max_retries: Option<i64>) -> Self
Set the restart policy to “on-failure” with optional retry count.
Set CPU shares (relative weight).
Sourcepub fn auto_remove(self, enable: bool) -> Self
pub fn auto_remove(self, enable: bool) -> Self
Enable auto-remove (container is deleted when it stops).
Sourcepub fn privileged(self, enable: bool) -> Self
pub fn privileged(self, enable: bool) -> Self
Enable privileged mode.
Sourcepub async fn build(self) -> Result<ContainerRef<'a>>
pub async fn build(self) -> Result<ContainerRef<'a>>
Build and create the container.
Returns a ContainerRef that can be used to interact with the container.
Auto Trait Implementations§
impl<'a> Freeze for ContainerBuilder<'a>
impl<'a> !RefUnwindSafe for ContainerBuilder<'a>
impl<'a> Send for ContainerBuilder<'a>
impl<'a> Sync for ContainerBuilder<'a>
impl<'a> Unpin for ContainerBuilder<'a>
impl<'a> !UnwindSafe for ContainerBuilder<'a>
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