Skip to content

Using the Sandboxed Shell Tool in Annolid

Annolid provides a Sandboxed Exec Tool that runs shell commands requested by the AI—or typed via direct chat commands (exec ... / !...)—inside an isolated, hardened Docker container rather than directly on your host machine.

How It Works

By default, Annolid restricts runtime tools to the configured workspace and verifies both the docker CLI and live Docker daemon reachability (docker info) before executing a shell command.

  • If Docker is running: Annolid runs the command in a labeled, --init-managed transient container using a reviewed official Ubuntu 24.04 image pinned to an immutable multi-architecture SHA-256 digest. It mounts your current workspace directory read-only (:ro), mounts a bounded noexec,nosuid,nodev tmpfs at /tmp with HOME=/tmp, drops all Linux capabilities (--cap-drop ALL), blocks privilege escalation (--security-opt no-new-privileges), disables network and IPC (--network none, --ipc none), uses a read-only root filesystem (--read-only), and enforces CPU, memory, and PID ceilings.
  • If a command times out or is canceled: Annolid forcefully stops and removes the named container (docker rm -f) in addition to terminating the CLI process so runaway containers are never left behind on the Docker daemon.
  • If Docker is missing or the daemon is stopped: the sandboxed command fails closed with the daemon diagnostic reason. Annolid does not silently run it on the host.

The workspace mount is read-only by default, and workspace path guards restrict shell command arguments to the configured workspace. The container's ephemeral /tmp tmpfs serves internal runtime temporary files and HOME=/tmp.

The secure defaults in ~/.annolid/config.json are equivalent to:

{
  "tools": {
    "restrictToWorkspace": true,
    "exec": {
      "timeout": 60,
      "containerImage": "ubuntu:24.04@sha256:4fbb8e6a8395de5a7550b33509421a2bafbc0aab6c06ba2cef9ebffbc7092d90",
      "networkNone": true,
      "dropAllCaps": true,
      "noNewPrivileges": true,
      "runAsHostUser": true,
      "pidsLimit": 256,
      "tmpfsTmp": true,
      "tmpfsSize": "128m",
      "hostMountReadOnly": true,
      "readOnlyRootfs": true,
      "memoryLimit": "512m",
      "cpusLimit": "1.0",
      "ipcNone": true,
      "allowHostFallback": false
    }
  }
}

The image reference must be a valid OCI reference ending in @sha256: followed by a 64-character lowercase hex digest; floating tags and malformed image references fail closed. Updating the sandbox base is therefore an explicit, reviewable config or source change.

Workspace restriction removes the host-backed exec_start and exec_process tools from the registered tool set. An existing config can explicitly adjust tools.exec limits (for example raising memoryLimit to "1g" or cpusLimit to "2.0") or weaken protections for a reviewed workflow, and annolid-run agent-security-audit flags weakened sandbox settings (sandbox-image-unpinned, sandbox-host-fallback-enabled, and sandbox-hardening-weakened).

Setup Instructions

To enable container isolation, install and start Docker on your computer:

macOS

  1. Download Docker Desktop for Mac from docker.com.
  2. Run the installer and move Docker to your Applications folder.
  3. Open Docker Desktop and follow the setup wizard.
  4. Keep the Docker app running in your menu bar when using Annolid.

Windows (WSL 2)

  1. Install Docker Desktop for Windows.
  2. Ensure you have the WSL 2 backend enabled during installation.
  3. Keep Docker Desktop running when you use Annolid.

Linux (Ubuntu/Debian)

  1. Run the following commands in your terminal:
sudo apt-get update
sudo apt-get install docker.io
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
  1. Log out and log back in for the docker group change to take effect.

Verifying It Works

You can check whether Annolid detects a reachable Docker daemon from the terminal:

annolid-run runtime check --skip-cli-smoke --json

Inspect the external_tools check's details.docker object for available, daemon_reachable, and server_version.

Once Docker is running, open the Annolid Bot chat and give it a read-only CLI-style task. For example:

"Run a command to list the Python files in this workspace."

While a sandboxed command is running, you can inspect transient Annolid containers from another terminal with:

docker ps --filter label=annolid.sandbox=true

Troubleshooting

  • "Sandbox unavailable" error: Ensure Docker Desktop or the Docker daemon is running (docker info) and that your user has permission to talk to the Docker socket. Once Docker starts, Annolid detects it on the next command without needing a restart.
  • Missing dependencies in the container: The pinned Ubuntu image is intentionally minimal, runs without network access, and is stateless. It cannot install packages during a command. Use Annolid's typed tools or configure a reviewed custom image pinned by digest.
  • "Sandbox image must be pinned" error: Replace a floating image tag with a reviewed digest reference. Run annolid-run agent-security-audit to inspect runtime sandbox posture.
  • Files disappear or workspace is read-only: The sandbox's /tmp is ephemeral and the workspace mount is read-only by default. Use Annolid's workspace file tools (write_file, edit_file, rename_file) for reviewed file changes.