pub struct ConfigBuilder { /* private fields */ }
Expand description
A Config
builder.
This type can be used to construct an instance Config
through a builder-like pattern.
§Examples
Construct a Config
example.
use docker_client::container::ConfigBuilder;
fn main() {
let builder = ConfigBuilder::with_image("alpine")
.name("example")
.hostname("localhost")
.expose_port("80/tcp")
.build();
println!("{:?}", builder);
}
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
Sourcepub fn with_image<T>(image: T) -> Self
pub fn with_image<T>(image: T) -> Self
Creates a new ConfigBuilder
initialized with image
.
This method returns an instance of ConfigBuilder
which can be used to create a Config
.
§Examples
Create a new CreationBuilder
with image.
let builder = ConfigBuilder::with_image("example-image").build();
Sourcepub fn name<T>(&mut self, name: T) -> &mut Self
pub fn name<T>(&mut self, name: T) -> &mut Self
Set name for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.name("example-name")
.build();
Sourcepub fn hostname<T>(&mut self, name: T) -> &mut Self
pub fn hostname<T>(&mut self, name: T) -> &mut Self
Set hostname for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.hostname("example-hostname")
.build();
Sourcepub fn domain_name<T>(&mut self, name: T) -> &mut Self
pub fn domain_name<T>(&mut self, name: T) -> &mut Self
Set domain name for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.domain_name("example-domainname")
.build();
Sourcepub fn user<T>(&mut self, name: T) -> &mut Self
pub fn user<T>(&mut self, name: T) -> &mut Self
Set user for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.user("example-user")
.build();
Sourcepub fn attach_stdin(&mut self, b: bool) -> &mut Self
pub fn attach_stdin(&mut self, b: bool) -> &mut Self
Set boolean flag attach_stdin
for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.attach_stdin(true)
.build();
Sourcepub fn attach_stdout(&mut self, b: bool) -> &mut Self
pub fn attach_stdout(&mut self, b: bool) -> &mut Self
Set boolean flag attach_stdout
for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.attach_stdout(true)
.build();
Sourcepub fn attach_stderr(&mut self, b: bool) -> &mut Self
pub fn attach_stderr(&mut self, b: bool) -> &mut Self
Set boolean flag attach_stderr
for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.attach_stderr(true)
.build();
Sourcepub fn expose_port<T>(&mut self, port: T) -> &mut Self
pub fn expose_port<T>(&mut self, port: T) -> &mut Self
Expose port of container to this Config builder.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.expose_port("22/tcp")
.build();
Sourcepub fn tty(&mut self, b: bool) -> &mut Self
pub fn tty(&mut self, b: bool) -> &mut Self
Set boolean flag tty
for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.tty(true)
.build();
Sourcepub fn open_stdin(&mut self, b: bool) -> &mut Self
pub fn open_stdin(&mut self, b: bool) -> &mut Self
Set boolean flag open_stdin
for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.open_stdin(true)
.build();
Sourcepub fn stdin_once(&mut self, b: bool) -> &mut Self
pub fn stdin_once(&mut self, b: bool) -> &mut Self
Set boolean flag stdin_once
for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.stdin_once(true)
.build();
Sourcepub fn env<T>(&mut self, env: T) -> &mut Self
pub fn env<T>(&mut self, env: T) -> &mut Self
Append environment variable for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.env("VAR=example-value")
.build();
Sourcepub fn cmd<T>(&mut self, cmd: T) -> &mut Self
pub fn cmd<T>(&mut self, cmd: T) -> &mut Self
Append command for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.cmd("example-cmd")
.build();
Sourcepub fn health_check(&mut self, health_check: Option<HealthCheck>) -> &mut Self
pub fn health_check(&mut self, health_check: Option<HealthCheck>) -> &mut Self
Set HealthCheck
for this container.
Sourcepub fn args_escaped(&mut self, b: bool) -> &mut Self
pub fn args_escaped(&mut self, b: bool) -> &mut Self
Sourcepub fn image<T>(&mut self, image: T) -> &mut Self
pub fn image<T>(&mut self, image: T) -> &mut Self
Set image for this container.
§Examples
let builder = ConfigBuilder::new()
.image("alpine")
.build();
Sourcepub fn volume<T>(&mut self, volume: T) -> &mut Self
pub fn volume<T>(&mut self, volume: T) -> &mut Self
Append volume for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.volume("/path/to/volume")
.build();
Sourcepub fn work_dir<T>(&mut self, work_dir: T) -> &mut Self
pub fn work_dir<T>(&mut self, work_dir: T) -> &mut Self
Set work directory for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.work_dir("/path/to/work_dir")
.build();
Sourcepub fn entry_point<T>(&mut self, entry_point: T) -> &mut Self
pub fn entry_point<T>(&mut self, entry_point: T) -> &mut Self
Append entry point script.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.entry_point("example-entry-point")
.build();
Sourcepub fn network_disabled(&mut self, b: bool) -> &mut Self
pub fn network_disabled(&mut self, b: bool) -> &mut Self
Sourcepub fn mac_address<T>(&mut self, mac_address: T) -> &mut Self
pub fn mac_address<T>(&mut self, mac_address: T) -> &mut Self
Set MAC address for this container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.mac_address("1A:2B:3C:4D:5E:6F")
.build();
Sourcepub fn on_build<T>(&mut self, cmd: T) -> &mut Self
pub fn on_build<T>(&mut self, cmd: T) -> &mut Self
Append on build script.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.on_build("command-on-build")
.build();
Sourcepub fn label<T, U>(&mut self, k: T, v: U) -> &mut Self
pub fn label<T, U>(&mut self, k: T, v: U) -> &mut Self
Append label of container.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.label("example-label-key", "example-label-value")
.build();
Sourcepub fn stop_signal<T>(&mut self, stop_signal: T) -> &mut Self
pub fn stop_signal<T>(&mut self, stop_signal: T) -> &mut Self
Set stop signal.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.stop_signal("command")
.build();
Sourcepub fn stop_timeout(&mut self, time: Option<i32>) -> &mut Self
pub fn stop_timeout(&mut self, time: Option<i32>) -> &mut Self
Set stop timeout.
§Examples
let builder = ConfigBuilder::with_image("alpine")
.stop_timeout(None)
.stop_timeout(Some(100))
.build();
Trait Implementations§
Source§impl Debug for ConfigBuilder
impl Debug for ConfigBuilder
Source§impl Default for ConfigBuilder
impl Default for ConfigBuilder
Source§fn default() -> ConfigBuilder
fn default() -> ConfigBuilder
Auto Trait Implementations§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
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> 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