Struct ConfigBuilder

Source
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

Source

pub fn new() -> Self

Creates a new default instance of ConfigBuilder to construct a Config.

Source

pub fn with_image<T>(image: T) -> Self
where T: Into<String>,

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();
Source

pub fn name<T>(&mut self, name: T) -> &mut Self
where T: Into<String>,

Set name for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .name("example-name")
    .build();
Source

pub fn hostname<T>(&mut self, name: T) -> &mut Self
where T: Into<String>,

Set hostname for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .hostname("example-hostname")
    .build();
Source

pub fn domain_name<T>(&mut self, name: T) -> &mut Self
where T: Into<String>,

Set domain name for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .domain_name("example-domainname")
    .build();
Source

pub fn user<T>(&mut self, name: T) -> &mut Self
where T: Into<String>,

Set user for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .user("example-user")
    .build();
Source

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();
Source

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();
Source

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();
Source

pub fn expose_port<T>(&mut self, port: T) -> &mut Self
where T: Into<String>,

Expose port of container to this Config builder.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .expose_port("22/tcp")
    .build();
Source

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();
Source

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();
Source

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();
Source

pub fn env<T>(&mut self, env: T) -> &mut Self
where T: Into<String>,

Append environment variable for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .env("VAR=example-value")
    .build();
Source

pub fn cmd<T>(&mut self, cmd: T) -> &mut Self
where T: Into<String>,

Append command for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .cmd("example-cmd")
    .build();
Source

pub fn health_check(&mut self, health_check: Option<HealthCheck>) -> &mut Self

Set HealthCheck for this container.

Source

pub fn args_escaped(&mut self, b: bool) -> &mut Self

Set args escaped for this container.

§Note

Only for Windows.

Source

pub fn image<T>(&mut self, image: T) -> &mut Self
where T: Into<String>,

Set image for this container.

§Examples
let builder = ConfigBuilder::new()
    .image("alpine")
    .build();
Source

pub fn volume<T>(&mut self, volume: T) -> &mut Self
where T: Into<String>,

Append volume for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .volume("/path/to/volume")
    .build();
Source

pub fn work_dir<T>(&mut self, work_dir: T) -> &mut Self
where T: Into<String>,

Set work directory for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .work_dir("/path/to/work_dir")
    .build();
Source

pub fn entry_point<T>(&mut self, entry_point: T) -> &mut Self
where T: Into<String>,

Append entry point script.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .entry_point("example-entry-point")
    .build();
Source

pub fn network_disabled(&mut self, b: bool) -> &mut Self

Set flag network_disabled for this container.

§Note
  • If b is false then network will enable.
  • If b is true then network will disable.
§Examples
let builder = ConfigBuilder::with_image("alpine")
    .network_disabled(true)
    .build();
Source

pub fn mac_address<T>(&mut self, mac_address: T) -> &mut Self
where T: Into<String>,

Set MAC address for this container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .mac_address("1A:2B:3C:4D:5E:6F")
    .build();
Source

pub fn on_build<T>(&mut self, cmd: T) -> &mut Self
where T: Into<String>,

Append on build script.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .on_build("command-on-build")
    .build();
Source

pub fn label<T, U>(&mut self, k: T, v: U) -> &mut Self
where T: Into<String>, U: Into<String>,

Append label of container.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .label("example-label-key", "example-label-value")
    .build();
Source

pub fn stop_signal<T>(&mut self, stop_signal: T) -> &mut Self
where T: Into<String>,

Set stop signal.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .stop_signal("command")
    .build();
Source

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();
Source

pub fn shell<T>(&mut self, cmd: T) -> &mut Self
where T: Into<String>,

Append shell command.

§Examples
let builder = ConfigBuilder::with_image("alpine")
    .shell("shell-command")
    .shell("shell-command-1")
    .build();
Source

pub fn build(&self) -> Config

Build Config from ConfigBuilder

§Examples
let builder = ConfigBuilder::with_image("alpine").build();

Trait Implementations§

Source§

impl Debug for ConfigBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ConfigBuilder

Source§

fn default() -> ConfigBuilder

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.