TestcontainerEx.Container.Lifecycle (testcontainer_ex v0.1.0)

Copy Markdown View Source

Orchestrates container lifecycle: create, start, wait, pull, copy.

This module is the bridge between the GenServer state and the Docker API. All functions require a connection and return {:ok, container} or {:error, reason}.

Summary

Functions

Creates and starts a container, applying wait strategies.

Stops a container by ID.

Functions

resolve_pull_policy(config, properties)

start_container(builder, conn, state)

@spec start_container(struct(), Tesla.Env.client(), map()) ::
  {:ok, TestcontainerEx.Container.Config.t()} | {:error, term()}

Creates and starts a container, applying wait strategies.

Steps:

  1. Build config with labels (via BuilderHelper)
  2. Check for reusable container or create new one
  3. Pull image if needed
  4. Copy files into container
  5. Start container
  6. Apply wait strategies
  7. Call after_start hook

stop_container(container_id, conn)

@spec stop_container(String.t(), Tesla.Env.client()) :: :ok | {:error, term()}

Stops a container by ID.