Struct testcontainers::core::RunnableImage
source · pub struct RunnableImage<I: Image> { /* private fields */ }
Expand description
Image wrapper that allows to override some of the image properties.
Implementations§
source§impl<I: Image> RunnableImage<I>
impl<I: Image> RunnableImage<I>
pub fn image(&self) -> &I
pub fn args(&self) -> &I::Args
pub fn network(&self) -> &Option<String>
pub fn container_name(&self) -> &Option<String>
pub fn env_vars(&self) -> Box<dyn Iterator<Item = (&String, &String)> + '_>
pub fn hosts(&self) -> Box<dyn Iterator<Item = (&String, &Host)> + '_>
pub fn mounts(&self) -> Box<dyn Iterator<Item = &Mount> + '_>
pub fn ports(&self) -> &Option<Vec<PortMapping>>
pub fn privileged(&self) -> bool
pub fn cgroupns_mode(&self) -> Option<CgroupnsMode>
pub fn userns_mode(&self) -> Option<String>
pub fn entrypoint(&self) -> Option<String>
pub fn descriptor(&self) -> String
pub fn ready_conditions(&self) -> Vec<WaitFor>
pub fn expose_ports(&self) -> Vec<u16>
pub fn exec_after_start(&self, cs: ContainerState) -> Vec<ExecCommand>
source§impl<I: Image> RunnableImage<I>
impl<I: Image> RunnableImage<I>
sourcepub fn with_args(self, args: I::Args) -> Self
pub fn with_args(self, args: I::Args) -> Self
Returns a new RunnableImage with the specified arguments.
§Examples
use testcontainers::{core::RunnableImage, GenericImage};
let image = GenericImage::default();
let args = vec!["arg1".to_string(), "arg2".to_string()];
let runnable_image = RunnableImage::from(image.clone()).with_args(args.clone());
assert_eq!(runnable_image.args(), &args);
let another_runnable_image = RunnableImage::from((image, args));
assert_eq!(another_runnable_image.args(), runnable_image.args());
sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Overrides the fully qualified image name (consists of {domain}/{owner}/{image}
).
Can be used to specify a custom registry or owner.
sourcepub fn with_tag(self, tag: impl Into<String>) -> Self
pub fn with_tag(self, tag: impl Into<String>) -> Self
Overrides the image tag.
There is no guarantee that the specified tag for an image would result in a running container. Users of this API are advised to use this at their own risk.
sourcepub fn with_container_name(self, name: impl Into<String>) -> Self
pub fn with_container_name(self, name: impl Into<String>) -> Self
Sets the container name.
sourcepub fn with_network(self, network: impl Into<String>) -> Self
pub fn with_network(self, network: impl Into<String>) -> Self
Sets the network the container will be connected to.
sourcepub fn with_env_var(
self,
(key, value): (impl Into<String>, impl Into<String>)
) -> Self
pub fn with_env_var( self, (key, value): (impl Into<String>, impl Into<String>) ) -> Self
Adds an environment variable to the container.
sourcepub fn with_host(self, key: impl Into<String>, value: impl Into<Host>) -> Self
pub fn with_host(self, key: impl Into<String>, value: impl Into<Host>) -> Self
Adds a host to the container.
sourcepub fn with_mount(self, mount: impl Into<Mount>) -> Self
pub fn with_mount(self, mount: impl Into<Mount>) -> Self
Adds a mount to the container.
sourcepub fn with_mapped_port<P: Into<PortMapping>>(self, port: P) -> Self
pub fn with_mapped_port<P: Into<PortMapping>>(self, port: P) -> Self
Adds a port mapping to the container.
sourcepub fn with_privileged(self, privileged: bool) -> Self
pub fn with_privileged(self, privileged: bool) -> Self
Sets the container to run in privileged mode.
sourcepub fn with_cgroupns_mode(self, cgroupns_mode: CgroupnsMode) -> Self
pub fn with_cgroupns_mode(self, cgroupns_mode: CgroupnsMode) -> Self
cgroup namespace mode for the container. Possible values are:
\"private\"
: the container runs in its own private cgroup namespace\"host\"
: use the host system’s cgroup namespace If not specified, the daemon default is used, which can either be\"private\"
or\"host\"
, depending on daemon version, kernel support and configuration.
sourcepub fn with_userns_mode(self, userns_mode: &str) -> Self
pub fn with_userns_mode(self, userns_mode: &str) -> Self
Sets the usernamespace mode for the container when usernamespace remapping option is enabled.
sourcepub fn with_shm_size(self, bytes: u64) -> Self
pub fn with_shm_size(self, bytes: u64) -> Self
Sets the shared memory size in bytes
Trait Implementations§
source§impl<I: Clone + Image> Clone for RunnableImage<I>
impl<I: Clone + Image> Clone for RunnableImage<I>
source§fn clone(&self) -> RunnableImage<I>
fn clone(&self) -> RunnableImage<I>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<I> Freeze for RunnableImage<I>
impl<I> RefUnwindSafe for RunnableImage<I>
impl<I> Send for RunnableImage<I>
impl<I> Sync for RunnableImage<I>
impl<I> Unpin for RunnableImage<I>
impl<I> UnwindSafe for RunnableImage<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 = ContainerAsync<I>> + Send + 'async_trait>>where
T: 'async_trait,
fn start<'async_trait>(
self
) -> Pin<Box<dyn Future<Output = ContainerAsync<I>> + Send + 'async_trait>>where
T: 'async_trait,
ContainerAsync
.