Skip to content

Containers

Docker container lifecycle management for agent containers.

CLASS DESCRIPTION
ContainerError

Raised when a container operation fails.

ContainerManager

Manages Docker container start/stop for configured agent types.

Classes

ContainerError

Bases: Exception

Raised when a container operation fails.

ContainerManager

ContainerManager()

Manages Docker container start/stop for configured agent types.

On startup, pull (if needed) and start agent containers. On shutdown, call stop_all to stop them. The container lifecycle manager registers URLs with the router after each successful start.

RAISES DESCRIPTION
ContainerError

If the Docker socket is unavailable at construction time.

METHOD DESCRIPTION
handle_container_exit

Handle an unexpected container exit with one restart attempt.

start_agent

Pull (if needed), start the container, wait for health, return URL.

stop_all

Stop all managed containers.

Functions

handle_container_exit
handle_container_exit(agent_type: str, *, image: str, port: int) -> None

Handle an unexpected container exit with one restart attempt.

If the container has already been restarted once and exits again, it is marked as permanently failed and no further restart is attempted.

PARAMETER DESCRIPTION
agent_type

Agent type identifier.

TYPE: str

image

Docker image to restart.

TYPE: str

port

Host port for the restarted container.

TYPE: int

start_agent
start_agent(agent_type: str, *, image: str, port: int) -> str

Pull (if needed), start the container, wait for health, return URL.

PARAMETER DESCRIPTION
agent_type

Agent type identifier (e.g. "issue-triage").

TYPE: str

image

Docker image name/tag to run.

TYPE: str

port

Host port to bind the container's port 8000 to.

TYPE: int

RETURNS DESCRIPTION
str

The base URL of the running container (e.g. "http://localhost:9001").

RAISES DESCRIPTION
ContainerError

If the container fails to become healthy.

stop_all
stop_all() -> None

Stop all managed containers.

Safe to call multiple times.