Daytona icon

Daytona

Manage Daytona sandboxes, snapshots, and volumes; run code and shell commands; drive a full Git pipeline; and manage the sandbox filesystem

Code → Run Command

AI-generated

Summary

Execute a shell command inside a Daytona sandbox environment, optionally creating a temporary ephemeral sandbox for the execution that is deleted afterward.

Inputs

  • Command (required) — Shell command string to run inside the sandbox.
  • Use Ephemeral Sandbox — Boolean flag to create a temporary sandbox for this execution, which is auto-deleted after running the command. Defaults to true.
  • Sandbox ID (required) — ID of an existing sandbox to run the command in; required if not using an ephemeral sandbox.
  • Snapshot — Snapshot ID or name to base the ephemeral sandbox on; used only if creating an ephemeral sandbox. If empty, the Daytona organization default snapshot is used.
  • Working Directory — Absolute directory path inside the sandbox where the command is executed; defaults to the sandbox home directory (/home/daytona).
  • Environment Variables — Set of environment variables to be available during command execution, specified as name-value pairs.
  • Timeout (Seconds) — Maximum time in seconds to wait for the command to finish executing; defaults to 60 seconds.
  • Wait Until Started Timeout (Seconds) — Maximum time to wait for the ephemeral sandbox to reach the "started" state before running the command; defaults to 60 seconds.

Output shape

a single item containing JSON with execution results

The output JSON includes 'exitCode' (number), 'result' (string output of the command), optional 'artifacts' object if any, 'sandboxId' indicating which sandbox was used, and a boolean 'ephemeral' indicating if the sandbox was temporary. If ephemeral, a cleanup attempt to delete the sandbox is made and any failure is included as a 'cleanupWarning' field.

Examples

Example 1: Run 'ls -la' in an ephemeral sandbox

Set Command to 'ls -la /home/daytona', leave Use Ephemeral Sandbox checked to create and auto-delete a temporary sandbox, optionally specify Snapshot if desired.

Example 2: Run a command in an existing sandbox

Set Command to the desired shell command, uncheck Use Ephemeral Sandbox, and provide the Sandbox ID of the existing sandbox to run the command in. Optionally specify working directory, environment variables, and timeouts as needed.

Links

Discussion