TestcontainerEx.Container.Config (testcontainer_ex v0.1.0)

Copy Markdown View Source

Container configuration struct and builder functions.

This module is pure data — no side effects, no Docker API calls. Use TestcontainerEx.Container.Builder for protocol-based build pipelines.

Summary

Types

t()

@type t() :: %TestcontainerEx.Container.Config{
  auth: term(),
  auto_remove: term(),
  bind_mounts: term(),
  bind_volumes: term(),
  check_image: term(),
  cmd: term(),
  container_id: term(),
  copy_to: term(),
  environment: term(),
  exposed_ports: term(),
  force_reuse: term(),
  hostname: term(),
  image: term(),
  ip_address: term(),
  labels: term(),
  name: term(),
  network: term(),
  network_mode: term(),
  privileged: term(),
  pull_policy: term(),
  reuse: term(),
  wait_strategies: term()
}

Functions

is_os(name)

(macro)

is_valid_image(check_image)

(macro)

mapped_port(container, port)

@spec mapped_port(t(), integer()) :: integer() | nil

new(image)

@spec new(String.t()) :: t()

os_type()

@spec os_type() :: :linux | :macos | :windows | :unknown

running_in_container?(dockerenv_path \\ "/.dockerenv", cgroup_path \\ "/proc/1/cgroup", k8s_secrets_path \\ "/var/run/secrets/kubernetes.io", containerenv_path \\ "/.containerenv")

@spec running_in_container?(String.t(), String.t(), String.t(), String.t()) ::
  boolean()

Returns true when running inside a container (Docker, Podman, Kubernetes).

Accepts optional overrides for the .dockerenv path, cgroup path, Kubernetes secrets path, and Podman containerenv path.

valid_image(config)

@spec valid_image(t()) :: {:ok, t()} | {:error, String.t()}

valid_image!(config)

@spec valid_image!(t()) :: t()

with_auth(config, username, password)

@spec with_auth(t(), String.t(), String.t()) :: t()

with_auto_remove(config, auto_remove)

@spec with_auto_remove(t(), boolean()) :: t()

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

@spec with_bind_mount(t(), String.t(), String.t(), String.t()) :: t()

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

@spec with_bind_volume(t(), String.t(), String.t(), boolean()) :: t()

with_check_image(config, check_image)

@spec with_check_image(t(), String.t() | Regex.t()) :: t()

with_cmd(config, cmd)

@spec with_cmd(t(), [String.t()]) :: t()

with_copy_to(config, target, source)

@spec with_copy_to(t(), String.t(), String.t()) :: t()

with_environment(config, key, value)

@spec with_environment(t(), atom() | String.t(), String.t()) :: t()

with_exposed_port(config, port)

@spec with_exposed_port(t(), integer()) :: t()

with_exposed_ports(config, ports)

@spec with_exposed_ports(t(), [integer()]) :: t()

with_fixed_port(config, port, host_port \\ nil)

@spec with_fixed_port(t(), integer(), integer() | nil) :: t()

with_force_reuse(config, force_reuse)

@spec with_force_reuse(t(), boolean()) :: t()

with_hostname(config, hostname)

@spec with_hostname(t(), String.t()) :: t()

with_label(config, key, value)

@spec with_label(t(), String.t(), String.t()) :: t()

with_name(config, name)

@spec with_name(t(), String.t()) :: t()

with_network(config, network_name)

@spec with_network(t(), String.t()) :: t()

with_network_mode(config, mode)

@spec with_network_mode(t(), String.t()) :: t()

with_privileged(config, privileged)

@spec with_privileged(t(), boolean()) :: t()

with_pull_policy(config, policy)

@spec with_pull_policy(
  t(),
  struct()
) :: t()

with_reuse(config, reuse)

@spec with_reuse(t(), boolean()) :: t()

with_waiting_strategies(config, wait_fns)

@spec with_waiting_strategies(t(), [struct()]) :: t()

with_waiting_strategy(config, wait_fn)

@spec with_waiting_strategy(
  t(),
  struct()
) :: t()