[−][src]Struct testcontainers::Container
Represents a running docker container.
Containers have a custom destructor
that removes them as soon as they go out of scope:
use testcontainers::*; #[test] fn a_test() { let docker = clients::Cli::default(); { let container = docker.run(MyImage::default()); // Docker container is stopped/removed at the end of this scope. } }
Methods
impl<'d, D, I> Container<'d, D, I> where
D: Docker,
I: Image,
[src]
D: Docker,
I: Image,
pub fn new(id: String, docker_client: &'d D, image: I) -> Self
[src]
Constructs a new container given an id, a docker client and the image.
This function will block the current thread (if wait_until_ready
is implemented correctly) until the container is actually ready to be used.
pub fn id(&self) -> &str
[src]
Returns the id of this container.
pub fn logs(&self) -> Logs
[src]
Gives access to the log streams of this container.
pub fn get_host_port(&self, internal_port: u16) -> Option<u16>
[src]
Returns the mapped host port for an internal port of this docker container.
This method does not magically expose the given port, it simply performs a mapping on the already exposed ports. If a docker image does not expose a port, this method will not be able to resolve it.
pub fn image(&self) -> &I
[src]
Trait Implementations
impl<'d, D: Debug, I: Debug> Debug for Container<'d, D, I> where
D: Docker,
I: Image,
[src]
D: Docker,
I: Image,
impl<'d, D, I> Drop for Container<'d, D, I> where
D: Docker,
I: Image,
[src]
D: Docker,
I: Image,
The destructor implementation for a Container.
As soon as the container goes out of scope, the destructor will either only stop or delete the docker container.
This behaviour can be controlled through the KEEP_CONTAINERS
environment variable. Setting it to true
will only stop containers instead of removing them. Any other or no value will remove the container.
Auto Trait Implementations
impl<'d, D, I> RefUnwindSafe for Container<'d, D, I> where
D: RefUnwindSafe,
I: RefUnwindSafe,
D: RefUnwindSafe,
I: RefUnwindSafe,
impl<'d, D, I> Send for Container<'d, D, I> where
D: Sync,
I: Send,
D: Sync,
I: Send,
impl<'d, D, I> Sync for Container<'d, D, I> where
D: Sync,
I: Sync,
D: Sync,
I: Sync,
impl<'d, D, I> Unpin for Container<'d, D, I> where
I: Unpin,
I: Unpin,
impl<'d, D, I> UnwindSafe for Container<'d, D, I> where
D: RefUnwindSafe,
I: UnwindSafe,
D: RefUnwindSafe,
I: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,