pub struct ContainerConfig {
pub image: String,
pub tag: String,
pub env_vars: HashMap<String, String>,
pub volumes: Vec<VolumeMount>,
pub startup_timeout: Duration,
pub command: Option<Vec<String>>,
pub cleanup_on_success: bool,
pub cleanup_on_failure: bool,
pub keep_logs: bool,
}Expand description
Container configuration for testcontainers
Fields§
§image: StringDocker image name (e.g., “ubuntu”)
tag: StringImage tag (e.g., “22.04”)
env_vars: HashMap<String, String>Environment variables
volumes: Vec<VolumeMount>Volume mounts
startup_timeout: DurationContainer startup timeout
command: Option<Vec<String>>Command override (entrypoint)
cleanup_on_success: boolContainer cleanup on success
cleanup_on_failure: boolContainer cleanup on failure
keep_logs: boolKeep logs before cleanup
Implementations§
Source§impl ContainerConfig
impl ContainerConfig
Sourcepub fn with_image(self, image: impl Into<String>) -> Self
pub fn with_image(self, image: impl Into<String>) -> Self
Set the Docker image
Sourcepub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add an environment variable
Sourcepub fn with_envs(self, envs: HashMap<String, String>) -> Self
pub fn with_envs(self, envs: HashMap<String, String>) -> Self
Add multiple environment variables
Sourcepub fn with_volume(self, volume: VolumeMount) -> Self
pub fn with_volume(self, volume: VolumeMount) -> Self
Add a volume mount
Sourcepub fn with_startup_timeout(self, timeout: Duration) -> Self
pub fn with_startup_timeout(self, timeout: Duration) -> Self
Set startup timeout
Sourcepub fn with_command(self, command: Vec<String>) -> Self
pub fn with_command(self, command: Vec<String>) -> Self
Set the container command
Sourcepub fn has_volumes(&self) -> bool
pub fn has_volumes(&self) -> bool
Check if any volumes are configured
Sourcepub fn has_env_vars(&self) -> bool
pub fn has_env_vars(&self) -> bool
Check if any environment variables are configured
Sourcepub fn cleanup_on_success(self, cleanup: bool) -> Self
pub fn cleanup_on_success(self, cleanup: bool) -> Self
Set cleanup behavior on success
Sourcepub fn cleanup_on_failure(self, cleanup: bool) -> Self
pub fn cleanup_on_failure(self, cleanup: bool) -> Self
Set cleanup behavior on failure
Trait Implementations§
Source§impl Clone for ContainerConfig
impl Clone for ContainerConfig
Source§fn clone(&self) -> ContainerConfig
fn clone(&self) -> ContainerConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContainerConfig
impl Debug for ContainerConfig
Auto Trait Implementations§
impl Freeze for ContainerConfig
impl RefUnwindSafe for ContainerConfig
impl Send for ContainerConfig
impl Sync for ContainerConfig
impl Unpin for ContainerConfig
impl UnwindSafe for ContainerConfig
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