SPAWNBOX

CLI

Use the spawnbox command for sandboxes, commands, terminals, files, templates, volumes and secrets.

The installer puts the spawnbox command in /usr/local/bin on the host. The CLI sends the same requests as the HTTP API.

  1. On the host, keep the server address and your API key:

    spawnbox login --url http://127.0.0.1:8080

    The CLI asks for the key. It keeps the address and the key in ~/.config/spawnbox/config.json. Only your user can read this file.

  2. Create a sandbox, run a command and delete the sandbox:

    S=$(spawnbox create --timeout 600)
    spawnbox exec $S -- uname -a
    spawnbox kill $S

    The exit code of spawnbox exec is the exit code of the command.

These are the other commands:

spawnbox ls                                   # list sandboxes
spawnbox sh $S                                # open a terminal
spawnbox cp ./src $S:/workspace/src           # copy files into a sandbox
spawnbox cp $S:/workspace/out.txt .           # copy files from a sandbox
spawnbox clone $S https://github.com/octocat/Hello-World
spawnbox ports publish $S 3000                # show the preview URL
spawnbox create --service-file services.json  # start services in a new sandbox
spawnbox services $S                          # show the state of its services
spawnbox services restart $S web
spawnbox services logs $S web --follow
spawnbox pause $S
spawnbox resume $S
spawnbox fork $S --count 3                    # print the IDs of 3 copies
spawnbox snapshot $S --name with-deps         # save as a template
spawnbox templates build ./py.json            # same body as POST /v1/templates
spawnbox templates build .devcontainer/devcontainer.json --devcontainer --name web
spawnbox secrets set openai --hosts api.openai.com --env OPENAI_API_KEY
spawnbox volumes create work --size 5         # a 5 GiB volume
spawnbox create -v work:/data                 # mount it at /data
spawnbox create -v work:/data:ro              # mount it to read only
spawnbox tenants create acme
spawnbox keys create --tenant acme --name acme-prod
spawnbox events --follow
spawnbox usage

To see all the options of a command, type spawnbox <command> --help. To get JSON output, add --json. To use the CLI from your computer, build it with cargo build --release -p spawnbox-cli and use the SSH tunnel from step 7.

You can also set the server address and the key with the environment variables SPAWNBOX_URL and SPAWNBOX_API_KEY.

This page is the “Use the CLI” section of README.md ↗. Found a mistake? Edit it on GitHub ↗