Share feedback
Answers are generated based on the documentation.

sbx env exec

DescriptionExecute a command inside a sandbox environment
Usagesbx env exec [flags] [PATH...] -- COMMAND [ARG...]

Experimental

This command is experimental.

Experimental features are intended for testing and feedback as their functionality or design may change between releases without warning or can be removed entirely in a future release.

Description

Run COMMAND in the sandbox declared in .sbxenv.yaml. The sandbox must already exist (see "sbx env create" and "sbx env run"); a stopped sandbox is started first.

Arguments before -- are environment-file paths, following the same rules as the other "sbx env" subcommands: each PATH may be a directory (the file is /.sbxenv.yaml) or the path to the environment file itself, and passing more than one deep-merges them in order. Without a -- every positional argument forms the command and the environment file is read from the current directory.

Flags match the behavior of "sbx 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
-D, --debugEnable debug logging

Examples

# Run a command in the environment declared in the current directory
sbx env exec go test ./...

# Open a shell
sbx env exec -it -- bash

# Run against explicitly merged environment files
sbx env exec .sbxenv.yaml override.yaml -- npm test