Docker Sandbox Tool: Securely Running Agents and Untrusted Code in Isolated VMs

Introduction

When a Coding Agent pulls dependencies, runs scripts, or tries out third-party packages, the host’s keys, repositories, and global environment often all sit behind the same lock. Dumping untrusted code directly into the local shell to execute is risky—a single malicious package or destructive command can cause damage that’s hard to undo. A more common compromise is to spin up a temporary container for a trial run, but if the container’s network and mount policies aren’t fully specified by hand, outbound traffic may still leak through or host directories might get modified by accident.

Below is an introduction to Docker Sandbox on SkillHub (coordinate: @clawhub_gitgoodordietrying/docker-sandbox). It organizes the usage of the Docker Desktop docker sandbox plugin into a reusable workflow in the form of a Skill: creating a lightweight VM with virtiofs workspace mounts, executing commands or launching various Agents inside the sandbox, and controlling traffic through a built-in network proxy with allowlist/denylist policies.

What Is This

Docker Sandbox is an Agent Skill maintained by gitgoodordietrying on ClawHub and distributed via SkillHub. The current version is 1.0.0, categorized under ai-agent, with the tag requires_api_key=false (the Skill itself does not mandate an API Key configuration).

Its positioning can be summarized in two sentences: create and manage Docker-based sandboxed VM environments; securely execute Agent tasks or untrusted code within an isolated environment. For upstream documentation and the full command reference, see the ClawHub repository page; the SkillHub entry page provides a Chinese summary and installation entry point.

  • SkillHub: https://www.skillhub.cn/skills/clawhub_gitgoodordietrying/docker-sandbox
  • Upstream: https://clawhub.ai/gitgoodordietrying/docker-sandbox
  • User-facing API endpoint: https://api.skillhub.cn/zcwl/docker-sandbox

Community data visible on the SkillHub page (subject to what the page displays): rating 100000, downloads 12446, installs 1368. If numbers here are inconsistent with historical figures, the current SkillHub page shall prevail.

Core Features

The following content is drawn from the upstream Skill documentation and describes the Docker Desktop sandbox plugin capabilities on the host side. The Skill guides the Agent to invoke these capabilities at appropriate times.

Isolated Execution Environment

Each sandbox corresponds to an independent lightweight VM with filesystem isolation. The specified workspace directory is mounted into the sandbox via virtiofs, making it easy to read and write project files within the isolated zone without expanding the host’s exposure surface.

Multi-Agent and Command Execution

Supports running Agents or arbitrary commands directly inside the sandbox. The Agent types listed in the documentation include: claude, codex, copilot, gemini, kiro, cagent. You can also use docker sandbox exec to run commands such as npm install or test builds in an existing sandbox.

Network Proxy Control

The sandbox includes a built-in outbound network proxy that can allow/block domains, configure CIDR denylists, bypass specific hosts, and set a default policy (deny or allow). You can use docker sandbox network log to inspect network activity inside the sandbox, facilitating auditing of suspicious package behavior.

Templates and Persistence

Supports --template to specify a custom image as the base environment, as well as docker sandbox save to persist the current sandbox state into a reusable template—ideal for teams sharing a fixed development environment.

Pre-installed Environment Inside the Sandbox (Upstream Documentation)

The sandbox VM ships with commonly used tools pre-installed, including Node.js (v20.x LTS), Git, Python, and curl/wget. The Agent’s home directory is /home/agent/, with a workspace/ symbolic link pointing to the mounted workspace. The documentation also notes that the Docker socket is exposed inside the sandbox, providing Docker-in-Docker capability. Proxy-related environment variables are set automatically by the environment, with a separate note on how to handle the case where Node.js fetch does not use the proxy by default.

Installation and Activation

Prerequisites

  • Docker Desktop 4.49+, with the docker sandbox plugin enabled.
  • Verify the plugin is available:
docker sandbox version

If it reports that the client version is too old, follow the upstream documentation to upgrade Docker Desktop to 4.49+ (the sandbox depends on engine API v1.44+).

Install the SkillHub CLI (if not already installed)

command -v skillhub && skillhub --version

If not installed, you can use the official install script (full installation or CLI-only; see the SkillHub installation docs):

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

Install This Skill

The SkillHub skill page requires installation following the SkillHub installation docs with the coordinate @clawhub_gitgoodordietrying/docker-sandbox. When installing, you must use --dir to point to the current Agent’s skills directory; otherwise it defaults to ./skills/ which may not be recognized.

skillhub install @clawhub_gitgoodordietrying/docker-sandbox --dir <skills directory>

Skills directories for each product (from the SkillHub installation docs; choose the one matching your current Agent):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project
  • Gemini CLI: ~/.gemini/skills/

After installation, restart or reload the skills as required by your Agent to activate SKILL.md. This Skill does not enforce API Key configuration at the Skill layer; actual cloud model invocations still depend on your existing configuration on the host or in the Agent environment.

Typical Usage

The following examples are drawn from the upstream Quick Start and Commands Reference, and can be reproduced directly provided the Docker version and plugin requirements are met.

Create a Sandbox for the Current Project

Run from the root directory of the current project. This creates an isolated environment named my-sandbox and mounts the current directory:

docker sandbox create --name my-sandbox claude .

Execute Commands Inside the Sandbox

docker sandbox exec my-sandbox node --version
docker sandbox exec my-sandbox npm install -g some-package
docker sandbox exec -w /path/to/workspace my-sandbox bash -c "ls -la"

Create and Run an Agent in One Step

docker sandbox run claude . -- -p "What files are in this project?"
docker sandbox run my-sandbox -- -p "Analyze this codebase"

Tighten Networking Before Exploring Untrusted Packages (Pattern Example)

Start with deny-all, then allow only npm-related domains, install and inspect package contents inside the sandbox, and finally verify outbound behavior with the network log:

docker sandbox create --name pkg-test claude .
docker sandbox network proxy pkg-test --policy deny
docker sandbox network proxy pkg-test --allow-host registry.npmjs.org
docker sandbox network proxy pkg-test --allow-host api.npmjs.org
docker sandbox exec pkg-test npm install -g suspicious-package
docker sandbox network log pkg-test
docker sandbox rm pkg-test

Common Lifecycle Commands

docker sandbox ls
docker sandbox stop <sandbox>
docker sandbox rm <sandbox>
docker sandbox reset

docker sandbox reset is used in scenarios such as sandboxes failing to start after a Docker upgrade. It clears all sandbox state, so confirm no instances need to be retained before running it.

Use Cases and Considerations

Who It’s For

  • You need an Agent to automatically execute untrusted code, install unknown npm packages, or run destructive tests, and you want it to default to an isolated VM rather than the host.
  • You need to run Agents under a controlled outbound network (e.g., allowing only the model API and GitHub).
  • You use Agents such as Claude, Codex, Copilot, or Gemini and want a unified reference for commands and mount paths.

Limitations and Notes

  1. Strong dependency on the Docker Desktop sandbox plugin. Pure Linux Engine or environments without Desktop must first confirm whether the official release supports equivalent capabilities. The documentation’s requirements are based on Desktop 4.49+.
  2. Workspace path mapping varies by host OS (path rules inside the sandbox differ for Windows/macOS/Linux). Cross-platform scripts should avoid hardcoding a single absolute path.
  3. Node.js fetch and the proxy: If code inside the sandbox relies on fetch for outbound access, the upstream documentation recommends using undici’s ProxyAgent as a require hook, or switching to curl; otherwise you may encounter “fetch failed.”
  4. Windows Git Bash: Paths may be transformed by MSYS. The documentation recommends setting MSYS_NO_PATHCONV=1 before the command.
  5. The Skill provides operational guidance and workflows, not a substitute for your own operational judgment on images, proxy policies, and the cleanup cadence of docker sandbox rm; long-running sandboxes still consume resources—stop or rm them promptly when done.

Closing

The Docker Sandbox Skill consolidates Docker Desktop sandbox creation, execution, network policy, and template capabilities into documentation that an Agent can follow. The core principle is: untrusted workloads go into the VM, the workspace is mounted via virtiofs, and outbound traffic goes through a configurable proxy. If you’re looking at ai-agent capabilities on SkillHub for Cursor or another Agent, you can install using the coordinate above and first run docker sandbox version to verify your environment.

  • SkillHub skill page: https://www.skillhub.cn/skills/clawhub_gitgoodordietrying/docker-sandbox
  • Upstream documentation and full command reference: https://clawhub.ai/gitgoodordietrying/docker-sandbox
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye