Struct contain_rs::Container
source · pub struct Container {
pub name: String,
pub image: Image,
pub command: Vec<String, Global>,
pub network: Option<Network>,
pub volumes: Vec<Volume, Global>,
pub port_mappings: Vec<PortMapping, Global>,
pub env_vars: Vec<EnvVar, Global>,
pub health_check: Option<HealthCheck>,
pub wait_strategy: Option<WaitStrategy>,
pub additional_wait_period: Duration,
}
Expand description
A container makes up the schedulable unit of this crate.
You can define an Image for it to be used and define port mappings and environment variables on it for example.
Fields§
§name: String
§image: Image
§command: Vec<String, Global>
§network: Option<Network>
§volumes: Vec<Volume, Global>
§port_mappings: Vec<PortMapping, Global>
§env_vars: Vec<EnvVar, Global>
§health_check: Option<HealthCheck>
§wait_strategy: Option<WaitStrategy>
§additional_wait_period: Duration
Implementations§
source§impl Container
impl Container
sourcepub fn from_image(image: Image) -> Container
pub fn from_image(image: Image) -> Container
Creates a new container from and Image
sourcepub fn name(&mut self, name: &str) -> &mut Container
pub fn name(&mut self, name: &str) -> &mut Container
Define a specific name for the container.
In case no explicit name is defined contain-rs will generate one as the name is being used by the crate::client::Client for interaction.
sourcepub fn command(&mut self, command: Vec<String, Global>) -> &mut Container
pub fn command(&mut self, command: Vec<String, Global>) -> &mut Container
Define an explicit command to run in the container.
pub fn arg<T>(&mut self, arg: T) -> &mut Containerwhere T: Into<String>,
pub fn map_ports<T, T2>(&mut self, ports: &[(T, T2)]) -> &mut Containerwhere T: Into<Port> + Clone, T2: Into<Port> + Clone,
pub fn volume(&mut self, name: &str, mount_point: &str) -> &mut Container
pub fn mount(&mut self, host_path: &str, mount_point: &str) -> &mut Container
sourcepub fn map_port(
&mut self,
source: impl Into<Port>,
target: impl Into<Port>
) -> &mut Container
pub fn map_port( &mut self, source: impl Into<Port>, target: impl Into<Port> ) -> &mut Container
Map a port from source
on the host to target
in the container.
sourcepub fn env_var<T>(&mut self, name: T, value: T) -> &mut Containerwhere
T: Into<String>,
pub fn env_var<T>(&mut self, name: T, value: T) -> &mut Containerwhere T: Into<String>,
Define an environment variable for the container.
sourcepub fn wait_for(&mut self, strategy: WaitStrategy) -> &mut Container
pub fn wait_for(&mut self, strategy: WaitStrategy) -> &mut Container
Add a WaitStrategy to be used when running the container.
sourcepub fn additional_wait_period(&mut self, period: Duration) -> &mut Container
pub fn additional_wait_period(&mut self, period: Duration) -> &mut Container
Add some additional wait time for concidering the container healthy.
Contain-rs waits this additional time after the WaitStrategy has been concidered successful.
sourcepub fn health_check(&mut self, health_check: HealthCheck) -> &mut Container
pub fn health_check(&mut self, health_check: HealthCheck) -> &mut Container
Add an arbitrary healthcheck to the container.
Some images may define healthchecks already, yet you can use this one to define one yourself explicitly.