Skip to content

API Reference parrot.tools.executors.docker

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.executors.docker

View source

Docker-backed remote tool executor.

Runs the envelope inside a Docker container using the async Docker Engine API (aiodocker). Two lifecycle modes:

  • "warm" (default) — a single long-lived container is created lazily and each envelope runs inside it via the Docker exec API. An idle TTL tears the container down after a period of inactivity so hosts don't accumulate stale sandboxes. Best latency.
  • "ephemeral" — a fresh container is created per call and force-removed afterwards. Strongest isolation (no state shared between calls) at the cost of container start latency.

The envelope is uploaded into the container filesystem via the Engine's put_archive API and the worker is invoked as python -m parrot.cli.tool_worker --envelope <path> — the same worker entrypoint (and the same sentinel-delimited stdout protocol) used by :class:K8sToolExecutor, so results parse identically across runtimes. A file upload is used instead of an attached stdin stream because the Engine's exec/attach websocket has no reliable stdin half-close, and the payload never appears in docker inspect or ps output.

Containers run with hardened defaults: all capabilities dropped, no-new-privileges, memory/CPU/pids limits, and a configurable network mode ("none" gives a fully offline sandbox).

This module's heavy dependency (aiodocker) is only imported when an executor instance is constructed, so projects that never use the Docker executor are not forced to install the client.

Note: Docker Sandboxes (the sbx microVM CLI) is a planned sibling executor behind the same interface once it grows a scriptable API; the policy registry reserves the "docker-sandbox" name for it.

Alias AbstractToolExecutor

Re-exported from parrot.tools.executors.abstract.AbstractToolExecutor.

Class DockerToolExecutor

Runs the envelope inside a Docker container.

Parameter Type Default Description
image Optional[str] None Container image that ships parrot.cli.tool_worker. Defaults to :data:parrot.conf.DOCKER_TOOL_IMAGE (the same worker image the K8s executor uses).
docker_host Optional[str] None Docker Engine endpoint (e.g. unix:///var/run/docker.sock or tcp://host:2375). Defaults to :data:parrot.conf.DOCKER_HOST; when empty the client auto-detects from the DOCKER_HOST environment variable or the default unix socket.
mode Optional[str] None "warm" reuses one long-lived container across calls (torn down after idle_ttl_seconds of inactivity); "ephemeral" creates and removes a container per call. Defaults to :data:parrot.conf.DOCKER_EXECUTOR_MODE.
idle_ttl_seconds Optional[int] None Idle time after which the warm container is removed. Defaults to :data:parrot.conf.DOCKER_IDLE_TTL_SECONDS.
network_mode Optional[str] None Docker network mode for the container. Defaults to :data:parrot.conf.DOCKER_NETWORK_MODE (bridge). Use "none" for tools that must run fully offline.
mem_limit Union[int, str] '512m' Memory limit ("512m" default) as a string with b/k/m/g suffix or an integer byte count.
nano_cpus int 500000000 CPU quota in units of 1e-9 CPUs. Defaults to half a CPU (500_000_000).
pids_limit int 256 Maximum number of processes in the container.
cap_drop Optional[List[str]] None Linux capabilities to drop. Defaults to ["ALL"].
security_opt Optional[List[str]] None Docker security options. Defaults to ["no-new-privileges"].
env Optional[Dict[str, str]] None Extra environment variables injected into the container (e.g. LLM API keys when dispatching Agents-as-Tools).
volumes Optional[List[str]] None Bind mounts in "host:container[:mode]" form.
labels Optional[Dict[str, str]] None Extra labels stamped on the container (merged with the executor's standard parrot-executor=true label).
pull_policy str 'missing' "missing" pulls the image only when absent locally, "always" pulls before every container creation, "never" never pulls.

Method DockerToolExecutor.execute

execute(envelope: ToolExecutionEnvelope) -> 'ToolResult'

Parameter Type Default Description
envelope ToolExecutionEnvelope

Returns: 'ToolResult'

Method DockerToolExecutor.close

close() -> None

Alias ToolExecutionEnvelope

Re-exported from parrot.tools.executors.abstract.ToolExecutionEnvelope.

Alias ToolResult

Re-exported from parrot.tools.abstract.ToolResult.

Attribute logger

Alias parse_sentinel_output

Re-exported from parrot.tools.executors.runner.parse_sentinel_output.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally