For the complete documentation index, see llms.txt. This page is also available as Markdown.
Benchmarked

Cloud Run

Use the Google Cloud Run sandbox provider for ComputeSDK to run isolated commands and filesystem operations inside Cloud Run. Choose remote mode for a deployed gateway, or direct mode for in-container sandbox CLI control.

Install and set up the Cloud Run provider

The Google Cloud Run provider works in two modes:

  • Remote mode — connect to a deployed Cloud Run gateway service. Set both CLOUD_RUN_SANDBOX_URL and CLOUD_RUN_SANDBOX_SECRET:

  • Direct mode — run your app inside a Cloud Run service deployed with gcloud beta run deploy --sandbox-launcher, and the provider drives the in-container sandbox CLI (default /usr/local/gcp/bin/sandbox). Override the binary with CLOUD_RUN_SANDBOX_BINARY.

Remote mode is selected automatically when both sandboxUrl and sandboxSecret are set; otherwise the provider runs in direct mode.

Cloud Run supports two execution modes for sandbox sessions:

  • Ephemeral mode (default) — create() creates a local logical handle only, runCommand() uses sandbox do, and destroy() removes local bookkeeping only.

  • Stateful mode — set executionMode: 'stateful' to have create() call sandbox run <id> --detach, runCommand() call sandbox exec <id>, and destroy() call sandbox delete <id>.

SDK method
Ephemeral mode (default)
Stateful mode

create()

Local logical handle only

sandbox run <id> --detach

runCommand()

sandbox do -- /bin/sh -c <command>

sandbox exec <id> -- /bin/sh -c <command>

destroy()

Local bookkeeping only

sandbox delete <id>

filesystem

Per-operation sandbox do

Per-operation sandbox exec <id>

Use the Cloud Run provider

Cloud Run configuration options

Supported ComputeSDK operations

Method
Supported
Notes

create

Ephemeral mode creates a logical handle; stateful mode starts a detached sandbox with sandbox run.

getById

Remote mode checks the gateway /v1/sandbox/info endpoint.

list

Returns sandboxes tracked in-process.

destroy

Ephemeral mode drops the handle; stateful mode deletes the detached sandbox.

runCommand

Uses sandbox do in ephemeral mode and sandbox exec in stateful mode.

getInfo

getUrl

Throws — Cloud Run Sandboxes do not expose per-sandbox ports through the sandbox CLI.

filesystem

Uses sandbox do in ephemeral mode and sandbox exec in stateful mode.

Cloud Run notes and limitations

  • Default command timeout is 300,000 ms (5 minutes).

  • Direct mode requires the service to be deployed with gcloud beta run deploy --sandbox-launcher, or the sandbox binary check will fail.

  • getUrl is not supported and throws for the requested port.

Last updated

Was this helpful?