Struct testcontainers::core::ContainerAsync
source · pub struct ContainerAsync<I: Image> { /* private fields */ }
Expand description
Represents a running docker container that has been started using an async client.
Containers have a custom destructor
that removes them as soon as they
go out of scope. However, async drop is not available in rust yet. This implementation
is using block_on.
use testcontainers::*;
#[tokio::test]
async fn a_test() {
let container = MyImage::default().start().await;
// Docker container is stopped/removed at the end of this scope.
}
Implementations§
source§impl<I> ContainerAsync<I>where
I: Image,
impl<I> ContainerAsync<I>where
I: Image,
sourcepub fn image_args(&self) -> &I::Args
pub fn image_args(&self) -> &I::Args
pub async fn ports(&self) -> Ports
sourcepub async fn get_host_port_ipv4(&self, internal_port: u16) -> u16
pub async fn get_host_port_ipv4(&self, internal_port: u16) -> u16
Returns the mapped host port for an internal port of this docker container, on the host’s IPv4 interfaces.
This method does not magically expose the given port, it simply performs a mapping on the already exposed ports. If a docker container does not expose a port, this method will panic.
§Panics
This method panics if the given port is not mapped. Testcontainers is designed to be used in tests only. If a certain port is not mapped, the container is unlikely to be useful.
sourcepub async fn get_host_port_ipv6(&self, internal_port: u16) -> u16
pub async fn get_host_port_ipv6(&self, internal_port: u16) -> u16
Returns the mapped host port for an internal port of this docker container, on the host’s IPv6 interfaces.
This method does not magically expose the given port, it simply performs a mapping on the already exposed ports. If a docker container does not expose a port, this method will panic.
§Panics
This method panics if the given port is not mapped. Testcontainers is designed to be used in tests only. If a certain port is not mapped, the container is unlikely to be useful.
sourcepub async fn get_bridge_ip_address(&self) -> IpAddr
pub async fn get_bridge_ip_address(&self) -> IpAddr
Returns the bridge ip address of docker container as specified in NetworkSettings.Networks.IPAddress
sourcepub async fn get_host_ip_address(&self) -> IpAddr
👎Deprecated since 0.16.6: Please use get_host
instead
pub async fn get_host_ip_address(&self) -> IpAddr
get_host
insteadReturns the host ip address of docker container
sourcepub async fn get_host(&self) -> Host
pub async fn get_host(&self) -> Host
Returns the host that this container may be reached on (may not be the local machine) Suitable for use in URL