testcontainer/network

Types

A Docker bridge network. Construct with create/1 (or with_network/2 for automatic cleanup) and pass the name to container.on_network/2.

pub opaque type Network

Values

pub fn create(name: String) -> Result(Network, error.Error)

Creates a new bridge network with the given name.

pub fn id(network: Network) -> String

The Docker-assigned network id.

pub fn name(network: Network) -> String

The network’s name (as passed to create/1).

pub fn remove(network: Network) -> Result(Nil, error.Error)

Removes a network created via create/1.

pub fn with_network(
  name: String,
  body: fn(Network) -> Result(a, error.Error),
) -> Result(a, error.Error)

Creates a network, runs body/1, then removes it. Cleanup runs even if body/1 returns an error or the caller process crashes (a linked guard process performs the removal asynchronously on caller down, retrying while container guards are still releasing the network’s endpoints).

use net <- network.with_network(“test-net”)

✨ Search Document