Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:23blocks OS Ai maestro Docker

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Containerization
Last Updated 2026-10-26 18:00 GMT

Overview

Docker Engine (or Podman) for creating and managing containerized AI agents with bind-mounted working directories and in-container tmux sessions.

Description

AI Maestro deploys agents inside Docker containers to isolate them from the host. The `agents-docker-service.ts` builds a `docker run` command with configurable CPU/memory limits, bind mounts (`-v`), environment variables (`-e`), and a container working directory pinned at `/workspace`. The container image (`agent-container/Dockerfile`) includes Node.js, tmux, and AI CLIs (Claude Code, Codex, Gemini). Container names follow the `aim-<name>` convention.

The `container-utils.ts` module provides thin CLI wrappers for inspecting container status, starting/stopping/removing containers, sending tmux keys inside containers via `docker exec`, and capturing pane content — all using shell-quoted argument strings. Container status detection distinguishes `running`, `stopped`, `missing`, and `docker_down` (daemon unreachable).

Usage

Use this environment when creating Docker-based agents via the dashboard or API. Required for the cloud-agent wake path (start container, exec tmux send-keys inside it) and for container hard-delete (remove the `aim-<name>` slot). Also used by ECS cloud agents that auto-build and push a Docker image.

System Requirements

Category Requirement Notes
OS Linux Docker daemon required; macOS via Docker Desktop
Software Docker Engine >= 20.10 Or Podman (scripts use `podman build`)
Disk Container image ~2GB Plus per-agent bind-mount working directories
Network Docker daemon socket `/var/run/docker.sock` must be accessible

Dependencies

System Packages

  • `docker` (Docker Engine CLI) or `podman`
  • Container image built from `agent-container/Dockerfile`

Node Packages

  • No additional npm packages — Docker is invoked via `child_process.exec` / `execFile`

Credentials

The following environment variables may be injected into containers:

  • `ANTHROPIC_API_KEY`: Claude API access
  • `GITHUB_TOKEN`: Git authentication inside container
  • Per-agent `extraEnv` map (validated: keys match `^[A-Za-z_][A-Za-z0-9_]*$`)

Quick Install

# Verify Docker is available
docker info

# Build the agent container image
podman build -t ai-maestro-dev -f Containerfile .
# or
docker build -t ai-maestro-agent -f agent-container/Dockerfile .

Code Evidence

Container status detection from `lib/container-utils.ts:39-60`:

export async function inspectContainerStatus(name: string): Promise<ContainerStatus> {
  try {
    const { stdout } = await execAsync(
      `docker container inspect ${shellQuote(name)} --format '{{.State.Status}}'`,
      { timeout: 5000 }
    )
    const status = stdout.trim()
    if (status === 'running' || status === 'paused' || status === 'created') {
      return status
    }
    return 'stopped'
  } catch (err) {
    if (/no such container|not found/i.test(msg)) return 'missing'
    if (/cannot connect to the docker daemon/i.test(msg)) return 'docker_down'
    return 'docker_down'
  }
}

In-container tmux send-keys from `lib/container-utils.ts:103-124`:

export async function sendKeysToContainer(containerName, sessionName, keys, opts) {
  const target = `${sessionName}:0.0`
  await execAsync(
    `docker exec ${shellQuote(containerName)} tmux send-keys -t ${shellQuote(target)} ${flag}${shellQuote(keys)}`,
    { timeout: 5000 }
  )
}

Docker availability check from `services/agents-cloud-service.ts:91-98`:

async function checkDockerAvailable(): Promise<boolean> {
  try {
    await execFileAsync('docker', ['info'], { timeout: 10000 })
    return true
  } catch { return false }
}

Common Errors

Error Message Cause Solution
`container name already in use` Hard-delete did not remove the `aim-<name>` container Run `docker rm aim-<name>` or wait for `removeContainer` to run
`docker_down` status Docker daemon not running Start the daemon: `systemctl start docker`
`cannot connect to the docker daemon` Socket permission Add user to `docker` group or check `/var/run/docker.sock` perms

Compatibility Notes

  • Podman: The `container:*` scripts use `podman build`; Docker CLI wrappers in `container-utils.ts` use `docker` commands directly. Podman's Docker-compatible CLI alias works.
  • Container CWD: Always `/workspace` (encoded as `-workspace` for Claude Code's project dir). Gemini uses a different encoding (`workspace`).
  • The container home is `/home/claude` — if the image's `USER` changes, update `CONTAINER_HOME` and the Dockerfile together.
  • Bind mount paths are validated against `["'\`$\n\r\\]` to prevent shell breakout from the quoted `-v` argument.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment