AAnvio
Runtimes & Model Routing

Docker Runtime

Container-sandboxed code execution — shipped, but not a full agent runtime, and streaming is not yet supported.

3 min read

DockerRuntimeProvider (packages/runtimes/src/docker/docker-runtime.ts) is a real, shipped runtime provider — but it is narrower than the vendor CLI runtimes. It exists to run sandboxed code execution inside a container, not to drive a full agent tool loop.

What it actually does

export class DockerRuntimeProvider implements RuntimeProvider {
  readonly runtimeId = 'docker' as const;

  capabilities(): RuntimeCapabilities {
    return {
      supportsTools: false,
      supportsStreaming: false,
      supportsSubagents: false,
      supportsMcp: false,
      supportedLanguages: ['javascript', 'python', 'shell'],
    };
  }

  isConfigured(): boolean {
    if (process.env.ANVIO_DOCKER_MOCK === '1') return true;
    const probe = spawnSync('docker', ['info'], { encoding: 'utf-8' });
    return probe.status === 0;
  }

  async run(request: RuntimeRequest): Promise<RuntimeResult> {
    if (!this.options.codeExecutor) {
      throw new Error('Docker runtime requires CodeExecutor');
    }
    const result = await this.options.codeExecutor.execute({
      code: request.input.content,
      runtime: 'docker',
      cwd: process.cwd(),
      timeoutMs: 60_000,
    });
    return {
      sessionId: request.session.id,
      content: result.stdout || result.stderr,
      usage: { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
      status: result.exitCode === 0 ? 'completed' : 'failed',
      runtimeId: 'docker',
    };
  }

  async *stream(): AsyncIterable<RuntimeStreamEvent> {
    yield { type: 'error', error: 'Docker runtime does not support streaming yet' };
  }
}

Key facts:

  • All four capability flags are false — no tools, no streaming, no subagents, no MCP. supportedLanguages is ['javascript', 'python', 'shell'].
  • It requires a CodeExecutor to be injected; without one, .run() throws immediately.
  • .stream() always yields an error event — streaming is explicitly not implemented, not silently degraded.
  • isConfigured() checks a real docker info subprocess call (or ANVIO_DOCKER_MOCK=1 for dev/test without a Docker daemon).

Configuration

# workspace/anvio.yaml
spec:
  execution:
    docker:
      enabled: false
      image: anvio/sandbox:latest
ANVIO_DOCKER_MOCK=1   # treat Docker as configured without a real daemon (dev/test only)

docker is registered as a RuntimeProviderId in RuntimeFactory, but it is not one of the five IDs valid for agent.spec.runtime.provider (local | cursor | claude-code | codex | antigravity). Docker is invoked as an execution backend for the CodeExecutor, not bound directly to an agent's runtime chain.

Relationship to the Code Execution Engine

Docker is one of five supported runtimes for Anvio's separate CodeExecutor sandbox (packages/execution/src/code-executor.ts), alongside shell, python, node, and go (which run as plain subprocesses with resource limits, not containers):

RuntimeSandboxDefault
Shellprocess limitsYes
Pythonsubprocess + limitsYes
Node.jssubprocess + limitsYes
Gosubprocess + limitsYes
Dockercontainer sandboxOptional

Security controls that apply regardless of which execution runtime is used: CPU/memory/disk limits, hard timeout (timeoutMs), every execution logged to workspace/audit/executions/ with an auditId, network disabled by default, filesystem scoped to the workspace or an agent's git worktree.

Not yet shipped

Docker as a fully first-class agent runtime provider — with tool support, streaming, and MCP the way local/claude-code/cursor have — is not implemented. Today DockerRuntimeProvider is a sandboxed code-execution backend reachable through the runtime abstraction, not an agent loop driver. Treat it as "run this code in a container," not "run this agent in a container."

Edit on GitHub

Last updated on

On this page