Share feedback
Answers are generated based on the documentation.

sbx exec

DescriptionExecute a command inside a sandbox
Usagesbx exec [flags] SANDBOX COMMAND [ARG...]

Description

Execute a command in a sandbox. If the sandbox is stopped, it is started first. Or — with --cloud — the cloud sandbox ID (sbx_*) or name from "sbx --cloud ls".

Flags match the behavior of "docker exec". Some flags (-d, --user, --privileged) are not supported with --cloud and are rejected rather than silently ignored. --detach-keys applies only to an interactive (-i/-t) cloud exec.

Options

OptionDefaultDescription
-d, --detachDetached mode: run command in the background
--detach-keysOverride the key sequence for detaching a container
-e, --envSet environment variables
--env-fileRead in a file of environment variables
-i, --interactiveKeep STDIN open even if not attached
--privilegedGive extended privileges to the command
-t, --ttyAllocate a pseudo-TTY
-u, --userUsername or UID (format: <name|uid>[:<group|gid>])
-w, --workdirWorking directory inside the container

Global options

OptionDefaultDescription
--cloudDispatch to Docker Cloud Sandboxes API instead of local sandboxd (supported by a growing set of verbs — run 'sbx --cloud --help' for the current list)
--cloud-api-urlhttps://api.sandboxes-cloud.docker.comCloud Sandboxes API base URL; only used with --cloud. Defaults to prod (https://api.sandboxes-cloud.docker.com). Set DOCKER_CLOUD_API_URL or pass this flag to override; a legacy value ending in /v1 is accepted.
-D, --debugEnable debug logging

Examples

# Open a shell inside a sandbox
sbx exec -it my-sandbox bash

# Run a command in the background
sbx exec -d my-sandbox npm start

# Run as root
sbx exec -u root my-sandbox apt-get update

# Cloud: run a command in a cloud sandbox by ID or name
sbx --cloud exec -it sbx_abc123 bash
sbx --cloud exec -it claude/my-sandbox bash