Install
openclaw skills install docker-docker-sandbox-agentA generic skill that provides a secure, temporary Docker sandbox for executing generated code (Python, Node.js, bash, etc.). Agents can use this to verify their code works without compromising the host machine.
openclaw skills install docker-docker-sandbox-agentExecute and verify code securely inside isolated temporary containers.
Agents frequently generate code (Python, JS, Shell scripts) that they need to test before presenting a final solution. Running this code directly on the host machine poses significant security and stability risks.
The docker-sandbox skill establishes a pattern for agents to provision a temporary, isolated container environment using Docker. Code executes inside the container, captures standard output and error, and cleans up immediately after completion.
--rm) after the process exits.When evaluating or testing code, use the following execution abstractions via the host terminal. Prepare your code in a local temporary directory (e.g., ./.sandbox/), then mount it in the container.
Run a python script securely with constrained memory and CPU.
# Create a test script
mkdir -p .sandbox
echo 'print("Hello from Docker Sandbox!")' > .sandbox/main.py
# Execute in python sandbox
docker run --rm \
--memory="512m" \
--cpus="1.0" \
--network none \
-v "$(pwd)/.sandbox:/app" \
-w /app \
python:3.10-slim python main.py
Evaluate JavaScript / Node.js safely.
docker run --rm \
--memory="512m" \
--cpus="1.0" \
--network none \
-v "$(pwd)/.sandbox:/app" \
-w /app \
node:18-alpine node main.js
Test shell scripts in a generic Alpine environment.
docker run --rm -v "$(pwd)/.sandbox:/app" -w /app alpine sh script.sh
/etc, ~/.ssh, or /) into the sandbox. Mount only the specifically designated .sandbox or task-related directory.--network none in the command to prevent the code from exfiltrating data or initiating unwanted network requests, unless network access is functionally necessary for the test.--privileged mode or run containers mapped directly to the root user of the host if preventable.