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>

source

pub fn image(&self) -> &I

source

pub fn args(&self) -> &I::Args

source

pub fn network(&self) -> &Option<String>

source

pub fn container_name(&self) -> &Option<String>

source

pub fn env_vars(&self) -> Box<dyn Iterator<Item = (&String, &String)> + '_>

source

pub fn hosts(&self) -> Box<dyn Iterator<Item = (&String, &Host)> + '_>

source

pub fn mounts(&self) -> Box<dyn Iterator<Item = &Mount> + '_>

source

pub fn ports(&self) -> &Option<Vec<PortMapping>>

source

pub fn privileged(&self) -> bool

source

pub fn cgroupns_mode(&self) -> Option<CgroupnsMode>

source

pub fn userns_mode(&self) -> Option<String>

source

pub fn shm_size(&self) -> Option<u64>

Shared memory size in bytes

source

pub fn entrypoint(&self) -> Option<String>

source

pub fn descriptor(&self) -> String

source

pub fn ready_conditions(&self) -> Vec<WaitFor>

source

pub fn expose_ports(&self) -> Vec<u16>

source

pub fn exec_after_start(&self, cs: ContainerState) -> Vec<ExecCommand>

source§

impl<I: Image> RunnableImage<I>

source

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

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.

source

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.

source

pub fn with_container_name(self, name: impl Into<String>) -> Self

Sets the container name.

source

pub fn with_network(self, network: impl Into<String>) -> Self

Sets the network the container will be connected to.

source

pub fn with_env_var( self, (key, value): (impl Into<String>, impl Into<String>) ) -> Self

Adds an environment variable to the container.

source

pub fn with_host(self, key: impl Into<String>, value: impl Into<Host>) -> Self

Adds a host to the container.

source

pub fn with_mount(self, mount: impl Into<Mount>) -> Self

Adds a mount to the container.

source

pub fn with_mapped_port<P: Into<PortMapping>>(self, port: P) -> Self

Adds a port mapping to the container.

source

pub fn with_privileged(self, privileged: bool) -> Self

Sets the container to run in privileged mode.

source

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

pub fn with_userns_mode(self, userns_mode: &str) -> Self

Sets the usernamespace mode for the container when usernamespace remapping option is enabled.

source

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>
where I::Args: Clone,

source§

fn clone(&self) -> RunnableImage<I>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<I: Debug + Image> Debug for RunnableImage<I>
where I::Args: Debug,

source§

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

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

impl<I: Image> From<(I, <I as Image>::Args)> for RunnableImage<I>

source§

fn from((image, image_args): (I, I::Args)) -> Self

Converts to this type from the input type.
source§

impl<I> From<I> for RunnableImage<I>
where I: Image, I::Args: Default,

source§

fn from(image: I) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<I> Freeze for RunnableImage<I>
where I: Freeze, <I as Image>::Args: Freeze,

§

impl<I> RefUnwindSafe for RunnableImage<I>

§

impl<I> Send for RunnableImage<I>

§

impl<I> Sync for RunnableImage<I>

§

impl<I> Unpin for RunnableImage<I>
where I: Unpin, <I as Image>::Args: Unpin,

§

impl<I> UnwindSafe for RunnableImage<I>
where I: UnwindSafe, <I as Image>::Args: UnwindSafe,

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, I> AsyncRunner<I> for T
where T: Into<RunnableImage<I>> + Send, I: Image,

source§

fn start<'async_trait>( self ) -> Pin<Box<dyn Future<Output = ContainerAsync<I>> + 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 = RunnableImage<I>> + 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> 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoResult<T> for T

§

type Err = Infallible

source§

fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>

source§

impl<T, I> SyncRunner<I> for T
where T: Into<RunnableImage<I>> + Send, I: Image,

source§

fn start(self) -> Container<I>

Starts the container and returns an instance of Container.
source§

fn pull_image(self) -> RunnableImage<I>

Pulls the image from the registry. Useful if you want to pull the image before starting the container.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more