pub struct ContainerRequest<I: Image> { /* private fields */ }
Expand description
Represents a request to start a container, allowing customization of the container.
Implementations§
Source§impl<I: Image> ContainerRequest<I>
impl<I: Image> ContainerRequest<I>
pub fn image(&self) -> &I
pub fn network(&self) -> &Option<String>
pub fn labels(&self) -> &BTreeMap<String, String>
pub fn container_name(&self) -> &Option<String>
pub fn env_vars(&self) -> impl Iterator<Item = (Cow<'_, str>, Cow<'_, str>)>
pub fn hosts(&self) -> impl Iterator<Item = (Cow<'_, str>, &Host)>
pub fn mounts(&self) -> impl Iterator<Item = &Mount>
pub fn copy_to_sources(&self) -> impl Iterator<Item = &CopyToContainer>
pub fn ports(&self) -> Option<&Vec<PortMapping>>
pub fn privileged(&self) -> bool
pub fn cap_add(&self) -> Option<&Vec<String>>
pub fn cap_drop(&self) -> Option<&Vec<String>>
pub fn cgroupns_mode(&self) -> Option<CgroupnsMode>
pub fn userns_mode(&self) -> Option<&str>
pub fn entrypoint(&self) -> Option<&str>
pub fn cmd(&self) -> impl Iterator<Item = Cow<'_, str>>
pub fn descriptor(&self) -> String
pub fn ready_conditions(&self) -> Vec<WaitFor>
pub fn expose_ports(&self) -> &[ContainerPort]
pub fn exec_after_start( &self, cs: ContainerState, ) -> Result<Vec<ExecCommand>, TestcontainersError>
Sourcepub fn startup_timeout(&self) -> Option<Duration>
pub fn startup_timeout(&self) -> Option<Duration>
Returns the startup timeout for the container.
pub fn working_dir(&self) -> Option<&str>
Sourcepub fn reuse(&self) -> ReuseDirective
pub fn reuse(&self) -> ReuseDirective
Indicates that the container will not be stopped when it is dropped
Sourcepub fn user(&self) -> Option<&str>
pub fn user(&self) -> Option<&str>
Returns the configured user that commands are run as inside the container.
pub fn security_opts(&self) -> Option<&Vec<String>>
pub fn readonly_rootfs(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<I> Freeze for ContainerRequest<I>where
I: Freeze,
impl<I> !RefUnwindSafe for ContainerRequest<I>
impl<I> Send for ContainerRequest<I>
impl<I> Sync for ContainerRequest<I>
impl<I> Unpin for ContainerRequest<I>where
I: Unpin,
impl<I> !UnwindSafe for ContainerRequest<I>
Blanket Implementations§
Source§impl<T, I> AsyncRunner<I> for T
impl<T, I> AsyncRunner<I> for T
Source§fn start<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerAsync<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
fn start<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerAsync<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
Starts the container and returns an instance of
ContainerAsync
.Source§fn pull_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerRequest<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
fn pull_image<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<ContainerRequest<I>, TestcontainersError>> + Send + 'async_trait>>where
T: 'async_trait,
Pulls the image from the registry.
Useful if you want to pull the image before starting the container.
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
Source§impl<RI, I> ImageExt<I> for RI
impl<RI, I> ImageExt<I> for RI
Source§fn with_cmd(
self,
cmd: impl IntoIterator<Item = impl Into<String>>,
) -> ContainerRequest<I>
fn with_cmd( self, cmd: impl IntoIterator<Item = impl Into<String>>, ) -> ContainerRequest<I>
Source§fn with_name(self, name: impl Into<String>) -> ContainerRequest<I>
fn with_name(self, name: impl Into<String>) -> ContainerRequest<I>
Overrides the fully qualified image name (consists of
{domain}/{owner}/{image}
).
Can be used to specify a custom registry or owner.Source§fn with_tag(self, tag: impl Into<String>) -> ContainerRequest<I>
fn with_tag(self, tag: impl Into<String>) -> ContainerRequest<I>
Overrides the image tag. Read more
Source§fn with_container_name(self, name: impl Into<String>) -> ContainerRequest<I>
fn with_container_name(self, name: impl Into<String>) -> ContainerRequest<I>
Sets the container name.
Source§fn with_network(self, network: impl Into<String>) -> ContainerRequest<I>
fn with_network(self, network: impl Into<String>) -> ContainerRequest<I>
Sets the network the container will be connected to.
Source§fn with_label(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> ContainerRequest<I>
fn with_label( self, key: impl Into<String>, value: impl Into<String>, ) -> ContainerRequest<I>
Adds the specified label to the container. Read more
Source§fn with_labels(
self,
labels: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>,
) -> ContainerRequest<I>
fn with_labels( self, labels: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)>, ) -> ContainerRequest<I>
Adds the specified labels to the container. Read more
Source§fn with_env_var(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> ContainerRequest<I>
fn with_env_var( self, name: impl Into<String>, value: impl Into<String>, ) -> ContainerRequest<I>
Adds an environment variable to the container.
Source§fn with_host(
self,
key: impl Into<String>,
value: impl Into<Host>,
) -> ContainerRequest<I>
fn with_host( self, key: impl Into<String>, value: impl Into<Host>, ) -> ContainerRequest<I>
Adds a host to the container.
Source§fn with_mount(self, mount: impl Into<Mount>) -> ContainerRequest<I>
fn with_mount(self, mount: impl Into<Mount>) -> ContainerRequest<I>
Adds a mount to the container.
Source§fn with_copy_to(
self,
target: impl Into<String>,
source: impl Into<CopyDataSource>,
) -> ContainerRequest<I>
fn with_copy_to( self, target: impl Into<String>, source: impl Into<CopyDataSource>, ) -> ContainerRequest<I>
Copies some source into the container as file
Source§fn with_mapped_port(
self,
host_port: u16,
container_port: ContainerPort,
) -> ContainerRequest<I>
fn with_mapped_port( self, host_port: u16, container_port: ContainerPort, ) -> ContainerRequest<I>
Adds a port mapping to the container, mapping the host port to the container’s internal port. Read more
Source§fn with_ulimit(
self,
name: &str,
soft: i64,
hard: Option<i64>,
) -> ContainerRequest<I>
fn with_ulimit( self, name: &str, soft: i64, hard: Option<i64>, ) -> ContainerRequest<I>
Adds a resource ulimit to the container. Read more
Source§fn with_privileged(self, privileged: bool) -> ContainerRequest<I>
fn with_privileged(self, privileged: bool) -> ContainerRequest<I>
Sets the container to run in privileged mode.
Source§fn with_cap_add(self, capability: impl Into<String>) -> ContainerRequest<I>
fn with_cap_add(self, capability: impl Into<String>) -> ContainerRequest<I>
Adds the capabilities to the container
Source§fn with_cap_drop(self, capability: impl Into<String>) -> ContainerRequest<I>
fn with_cap_drop(self, capability: impl Into<String>) -> ContainerRequest<I>
Drops the capabilities from the container’s capabilities
Source§fn with_cgroupns_mode(self, cgroupns_mode: CgroupnsMode) -> ContainerRequest<I>
fn with_cgroupns_mode(self, cgroupns_mode: CgroupnsMode) -> ContainerRequest<I>
cgroup namespace mode for the container. Possible values are: Read more
Source§fn with_userns_mode(self, userns_mode: &str) -> ContainerRequest<I>
fn with_userns_mode(self, userns_mode: &str) -> ContainerRequest<I>
Sets the usernamespace mode for the container when usernamespace remapping option is enabled.
Source§fn with_shm_size(self, bytes: u64) -> ContainerRequest<I>
fn with_shm_size(self, bytes: u64) -> ContainerRequest<I>
Sets the shared memory size in bytes
Source§fn with_startup_timeout(self, timeout: Duration) -> ContainerRequest<I>
fn with_startup_timeout(self, timeout: Duration) -> ContainerRequest<I>
Sets the startup timeout for the container. The default is 60 seconds.
Source§fn with_working_dir(self, working_dir: impl Into<String>) -> ContainerRequest<I>
fn with_working_dir(self, working_dir: impl Into<String>) -> ContainerRequest<I>
Sets the working directory. The default is defined by the underlying image, which in turn may default to
/
.Source§fn with_log_consumer(
self,
log_consumer: impl LogConsumer + 'static,
) -> ContainerRequest<I>
fn with_log_consumer( self, log_consumer: impl LogConsumer + 'static, ) -> ContainerRequest<I>
Adds the log consumer to the container. Read more
Source§fn with_reuse(self, reuse: ReuseDirective) -> ContainerRequest<I>
fn with_reuse(self, reuse: ReuseDirective) -> ContainerRequest<I>
Flag the container as being exempt from the default
testcontainers
remove-on-drop lifecycle,
indicating that the container should be kept running, and that executions with the same configuration
reuse it instead of starting a “fresh” container instance. Read moreSource§fn with_user(self, user: impl Into<String>) -> ContainerRequest<I>
fn with_user(self, user: impl Into<String>) -> ContainerRequest<I>
Sets the user that commands are run as inside the container.
Source§fn with_readonly_rootfs(self, readonly_rootfs: bool) -> ContainerRequest<I>
fn with_readonly_rootfs(self, readonly_rootfs: bool) -> ContainerRequest<I>
Sets the container’s root filesystem to be mounted as read-only
Source§fn with_security_opt(
self,
security_opt: impl Into<String>,
) -> ContainerRequest<I>
fn with_security_opt( self, security_opt: impl Into<String>, ) -> ContainerRequest<I>
Sets security options for the container
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Source§impl<T, I> SyncRunner<I> for T
impl<T, I> SyncRunner<I> for T
Source§fn start(self) -> Result<Container<I>, TestcontainersError>
fn start(self) -> Result<Container<I>, TestcontainersError>
Starts the container and returns an instance of
Container
.Source§fn pull_image(self) -> Result<ContainerRequest<I>, TestcontainersError>
fn pull_image(self) -> Result<ContainerRequest<I>, TestcontainersError>
Pulls the image from the registry.
Useful if you want to pull the image before starting the container.