View Source Testcontainers.Container (testcontainers v1.11.6)

A struct with builder functions for creating a definition of a container.

Summary

Functions

Returns true if term is a valid check_image, otherwise returns false.

Gets the host port on the container for the given exposed port.

A constructor function to make it easier to construct a container

Check if the provided image is compatible with the expected default image.

Check if the provided image is compatible with the expected default image.

Adds authentication token for registries that require a login.

Sets whether the container should be automatically removed on exit.

Sets a file or the directory on the host machine to be mounted into a container.

Sets a volume to be mounted into a container on target path

Set the regular expression to check the image validity.

Sets a cmd to run when the container starts.

Sets an environment variable to the container.

Adds a port to be exposed on the container.

Adds multiple ports to be exposed on the container.

Adds a fixed port to be exposed on the container. This approach to managing ports is not recommended by Testcontainers. Use at your own risk.

Sets a label to apply to the container object in docker.

Sets a network mode to apply to the container object in docker.

Sets whether the container should be reused if it is already running.

Sets multiple waiting strategies for the container.

Sets a waiting strategy for the container.

Functions

Link to this macro

is_valid_image(check_image)

View Source (macro)

Returns true if term is a valid check_image, otherwise returns false.

Link to this function

mapped_port(container, port)

View Source

Gets the host port on the container for the given exposed port.

A constructor function to make it easier to construct a container

Check if the provided image is compatible with the expected default image.

Check if the provided image is compatible with the expected default image.

Raises:

ArgumentError when image isn't compatible.

Link to this function

with_auth(config, username, password)

View Source

Adds authentication token for registries that require a login.

Link to this function

with_auto_remove(config, auto_remove)

View Source

Sets whether the container should be automatically removed on exit.

Link to this function

with_bind_mount(config, host_src, container_dest, options \\ "ro")

View Source

Sets a file or the directory on the host machine to be mounted into a container.

Link to this function

with_bind_volume(config, volume, container_dest, read_only \\ false)

View Source

Sets a volume to be mounted into a container on target path

Link to this function

with_check_image(config, check_image)

View Source

Set the regular expression to check the image validity.

When using a string, it will compile it to a regular expression. If the compilation fails, it will raise a Regex.CompileError.

Sets a cmd to run when the container starts.

Link to this function

with_environment(config, key, value)

View Source

Sets an environment variable to the container.

Link to this function

with_exposed_port(config, port)

View Source

Adds a port to be exposed on the container.

Link to this function

with_exposed_ports(config, ports)

View Source

Adds multiple ports to be exposed on the container.

Link to this function

with_fixed_port(config, port, host_port \\ nil)

View Source

Adds a fixed port to be exposed on the container. This approach to managing ports is not recommended by Testcontainers. Use at your own risk.

Link to this function

with_force_reuse(config, force_reuse)

View Source
Link to this function

with_label(config, key, value)

View Source

Sets a label to apply to the container object in docker.

Link to this function

with_network_mode(config, mode)

View Source

Sets a network mode to apply to the container object in docker.

Link to this function

with_reuse(config, reuse)

View Source

Sets whether the container should be reused if it is already running.

Link to this function

with_waiting_strategies(config, wait_fns)

View Source

Sets multiple waiting strategies for the container.

Link to this function

with_waiting_strategy(config, wait_fn)

View Source

Sets a waiting strategy for the container.