Deploy this Worker to write a script into a named Container and run it. For step-by-step guides, see Run a Linux command and Move files in and out of a sandbox.
Done when POST .../run returns hello from the sandbox in stdout.
npm create cloudflare@latest -- workspace --template=cloudflare/sandbox-sdk/examples/workspace
cd workspace
npm run deployprintf 'printf "hello from the sandbox\n"\n' | \
curl --request PUT --data-binary @- \
"$WORKER_URL/sandboxes/agent-1/source"
curl --request POST "$WORKER_URL/sandboxes/agent-1/run"Read while that Container is still running:
curl "$WORKER_URL/sandboxes/agent-1/source"Write agent-2 to confirm names are isolated:
printf 'printf "hello from agent 2\n"\n' | \
curl --request PUT --data-binary @- \
"$WORKER_URL/sandboxes/agent-2/source"
curl "$WORKER_URL/sandboxes/agent-1/source"
curl "$WORKER_URL/sandboxes/agent-2/source"Reset that Container:
curl --request DELETE "$WORKER_URL/sandboxes/agent-1/execution"The Durable Object remains. The next start has a fresh disk unless you restore a snapshot.
Authenticate in production. Derive the name from your user or job. This Worker runs submitted shell.