testcontainers library
Classes
- BytesTransferable
- Wraps raw bytes to be copied into a container.
- ComparableVersion
- A parsed semantic version that supports full ordering.
- CompositeWaitStrategy
- Chains multiple wait strategies and runs them in sequence.
- ContainerAddress
- A single IP address assigned to a container's secondary network interface.
- ContainerBindOptions
- Mount propagation options for a bind mount.
- ContainerBlkioDeviceRate
- A single entry in a blkio device I/O rate list.
- ContainerBlkioWeightDevice
-
A single entry in the
BlkioWeightDevicehost-config list. - ContainerConfig
- The container-level configuration as stored in the image or overridden at run time.
- ContainerDeviceMapping
- A host device exposed inside the container.
- ContainerDeviceRequest
- A request for generic device access (e.g. GPU via the NVIDIA device plugin).
- ContainerGraphDriver
- The storage driver and its metadata for a container's writable layer.
- ContainerHealth
- The aggregated health status of a container.
- ContainerHealthcheck
- The health-check configuration baked into an image or specified at container creation time.
- ContainerHostConfig
- The host configuration applied when the container was created.
- ContainerImageManifestDescriptor
- Describes a layer in an image manifest (OCI image spec).
- ContainerImageOptions
- Options for an image-based mount.
- ContainerInspectInfo
- The complete inspect response for a single Docker container.
- ContainerIPAMConfig
- Static IP configuration for a network endpoint (IPAM).
- ContainerLog
- A single health-check execution record.
- ContainerLogConfig
- Logging driver configuration for a container.
- ContainerMount
- A volume or bind mount that is currently attached to a running container.
- ContainerMountPoint
-
A mount point attached to the container (as declared in
HostConfig.Mounts). - ContainerNetworkEndpoint
- A container's connection details on a single Docker network.
- ContainerNetworkSettings
- The complete network configuration of a running container.
- ContainerPlatform
- The platform (OS and architecture) of a container image.
- ContainerPortBinding
- A single host-to-container port binding.
- ContainerRestartPolicy
- The restart policy applied to a container.
- ContainerState
- The full lifecycle state of a container.
- ContainerStatusWaitStrategy
-
Waits until the container's lifecycle status is
'running'. - ContainerTmpfsOptions
-
Options for a
tmpfs(in-memory) mount. - ContainerUlimit
- A ulimit (resource limit) applied to the container.
- ContainerVolumeDriverConfig
- Driver configuration for a named volume.
- ContainerVolumeOptions
- Options for a volume mount.
- DockerClient
- A thin HTTP client that speaks directly to the Docker Engine API.
- DockerContainer
- A Docker container managed by testcontainers-dart.
- DockerImage
- A Docker image built from a local context directory.
- ExecWaitStrategy
- Waits until a command executed inside the container exits with the expected exit code.
- FileExistsWaitStrategy
- Waits until a specific file exists on the container's filesystem.
- HealthcheckWaitStrategy
-
Waits until a container's Docker health check reports
'healthy'. - HttpWaitStrategy
- Waits until an HTTP endpoint inside the container returns an acceptable response.
- LogMessageWaitStrategy
- Waits until a specific log message appears in the container's output.
- Network
- A Docker user-defined network managed by testcontainers-dart.
- PathTransferable
- Wraps a local FileSystemEntity (file or directory) to be copied into a container.
- PortWaitStrategy
- Waits until a TCP connection to the specified port can be established.
- Reaper
- Singleton that manages the Ryuk resource-reaper side-car container.
- TestcontainersConfiguration
- Holds all runtime-tunable configuration for testcontainers-dart.
- Transferable
- Base type for content that can be copied into a running container.
- WaitStrategy
- Abstract base class for all wait strategies.
- WaitStrategyTarget
- The interface that must be implemented by any object that can be passed to WaitStrategy.waitUntilReady.
Enums
- ConnectionMode
- Determines how DockerClient computes the host IP address and port for containers.
Constants
- kDefaultTransferMode → const int
- Default Unix file permission bits used when copying files into containers.
- labelLang → const String
- Label key identifying the language binding.
- labelLangValue → const String
- The language binding identifier placed in labelLang.
- labelSessionId → const String
- Label key carrying the unique session identifier.
- labelTestcontainers → const String
- Label key indicating that the resource was created by testcontainers.
- labelVersion → const String
- Label key carrying the testcontainers library version.
-
notExitedStatuses
→ const Set<
String> - Container statuses that indicate the container is still alive and worth continuing to poll.
- tcVersion → const String
- The current version of this Dart testcontainers library.
- testcontainersNamespace → const String
- The root namespace for all testcontainers Docker labels.
Properties
- sessionId → String
-
A UUID that is unique to the current Dart process.
final
- testcontainersConfig → TestcontainersConfiguration
-
The process-wide testcontainers configuration singleton.
final
Functions
-
buildTransferTar(
Transferable transferable, String destination, {int mode = kDefaultTransferMode}) → Uint8List -
Builds an in-memory tar archive from
transferableand returns the raw bytes ready to be uploaded viaPUT /containers/{id}/archive?path=/. -
createLabels(
String image, Map< String, String> ? labels) → Map<String, String> - Returns the standard set of Docker labels for a container or network.
-
defaultGatewayIp(
) → String? - Returns the host machine's default-route gateway IP address.
-
dockerAuthConfig(
) → String? -
Returns the raw
DOCKER_AUTH_CONFIGstring, ornull. -
dockerHost(
) → String? - Returns the effective Docker host from the configuration or environment.
-
dockerHostHostname(
) → String? - Returns the hostname portion of an SSH-based Docker host URL.
-
dockerSocket(
) → String - Returns the path to the Docker Unix socket.
-
insideContainer(
) → bool -
Returns
truewhen the current process is running inside a Docker container. -
isArm(
) → bool -
Returns
truewhen the current CPU architecture is ARM (64-bit). -
isLinux(
) → bool -
Returns
truewhen the current platform is Linux. -
isMac(
) → bool -
Returns
truewhen the current platform is macOS. -
isSshDockerHost(
) → bool -
Returns
truewhen the Docker host is reached via SSH. -
isWindows(
) → bool -
Returns
truewhen the current platform is Windows. -
overriddenConnectionMode(
) → ConnectionMode? -
Parses the
TESTCONTAINERS_CONNECTION_MODEenvironment variable. -
parseDockerAuthConfig(
String authConfig) → List< DockerAuthInfo> ? -
Parses a JSON Docker
config.json-style auth configuration string. -
readTcProperties(
) → Map< String, String> -
Reads
~/.testcontainers.propertiesand returns its key-value pairs. -
runningContainerId(
) → String? -
Returns the Docker container ID of the current process, or
null. -
throwStopIteration(
) → void -
Throws
_StopIterationto signal that the poll loop should stop immediately without waiting for the timeout. -
waitForLogs(
WaitStrategyTarget container, Pattern predicate, {Duration? timeout, Duration interval = const Duration(seconds: 1), bool predicateStreamsAnd = false}) → Future< Duration> - Convenience function that waits for container log output to match a pattern.
Typedefs
- DockerAuthInfo = ({String password, String registry, String username})
- Holds the credentials required to authenticate against a single Docker registry.
- TransferSpec = (Transferable, String, int)
- A specification describing a single copy-into-container operation.
Exceptions / Errors
- ContainerConnectException
- Thrown when a running container cannot be reached over the network.
- ContainerIsNotRunning
-
Thrown when an operation requires a running container but the container is
not (or is no longer) in the
runningstate. - ContainerStartException
- Thrown when a container cannot be started.
- NoSuchPortExposed
- Thrown when a requested port is not exposed by the container.