Containers
Docker container lifecycle management for agent containers.
Classes:
-
ContainerError–Raised when a container operation fails.
-
ContainerManager–Manages Docker container start/stop for configured agent types.
ContainerError
¶
Bases: Exception
Raised when a container operation fails.
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:
-
ContainerError–If the Docker socket is unavailable at construction time.
Methods:
-
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.
handle_container_exit
¶
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.
Parameters:
-
agent_type(str) –Agent type identifier.
-
image(str) –Docker image to restart.
-
port(int) –Host port for the restarted container.
start_agent
¶
start_agent(agent_type: str, *, image: str, port: int, environment: dict[str, str] | None = None) -> str
Pull (if needed), start the container, wait for health, return URL.
Parameters:
-
agent_type(str) –Agent type identifier (e.g.
"issue-triage"). -
image(str) –Docker image name/tag to run.
-
port(int) –Host port to bind the container's port 8000 to.
-
environment(dict[str, str] | None, default:None) –Optional dictionary of environment variables to pass to the container.
Returns:
-
str–The base URL of the running container (e.g.
"http://localhost:9001").
Raises:
-
ContainerError–If the container fails to become healthy.