Sandboxes quick start

4 min read

This guide takes a server you already manage with Teploy to a running sandbox using teploy sandbox. Sandboxes are early access and self-hosted on your own server (engine: teploy-sandbox v0.1.0).

Prerequisites

  • A server configured in Teploy with systemd and Docker (as teploy setup leaves them).
  • Root or passwordless sudo on the server for every teploy sandbox command (host to install and manage the service; the other commands to read the engine's root-only token in /var/lib/teploy-sandbox).
  • SSH TCP forwarding enabled on the server's sshd (this is the default; if AllowTcpForwarding no is set, the CLI detects and reports it).

1. Install the engine on a server

teploy sandbox host prod

teploy sandbox host downloads the pinned teploy-sandbox v0.1.0 binary from GitHub releases, verifies its SHA-256 against the hash pinned in the CLI and the release checksum before uploading, confirms the binary reports the expected version on the server, and starts it as the teploy-sandbox systemd service listening on 127.0.0.1:7439.

host installs the Docker driver only (teploy sandbox host --driver vm is refused; the experimental VM driver requires separate host setup).

Running teploy sandbox host prod again is safe: it does nothing if the same release and unit file are already running, starts a stopped service, and upgrades an older release (saving the previous binary as /usr/local/bin/teploy-sandbox.prev and rolling back automatically if the new engine does not answer).

2. Create a sandbox and run a command

Create a sandbox from any Docker image on the server:

teploy sandbox new --host prod --image alpine:3.20

The command prints Created <id> on <server> (<image>, expires <time>) along with a suggested teploy sandbox exec command (pass --json to parse .run.id in scripts). List sandboxes on the server:

teploy sandbox ls --host prod

Run a command inside it and stream its output:

teploy sandbox exec 01JCV5ZK3Q7X9B2D4E6F8A0B1C --host prod -- echo hello

After --, a single word is passed as a shell command line so shell syntax such as pipes or redirects works inside one quoted argument; multiple words are each quoted as your shell tokenized them so argument quoting survives (for example -- echo 'a b'):

teploy sandbox exec 01JCV5ZK3Q7X9B2D4E6F8A0B1C --host prod -- 'ls -la /work | wc -l'

By default the sandbox has no outbound network (--network none). To let package managers reach allowlisted registries, pass --network allowlist when creating it.

3. Copy files in and out

Copy a single file (up to 64 MiB) into or out of the sandbox's /work directory using <id>:<path>:

teploy sandbox cp app.tar.gz 01JCV5ZK3Q7X9B2D4E6F8A0B1C:app.tar.gz --host prod
teploy sandbox cp 01JCV5ZK3Q7X9B2D4E6F8A0B1C:out/report.pdf . --host prod

Paths are relative to /work (or may be written in full as /work/...).

4. Stop, resume, fork, and remove

Stop a sandbox to keep its filesystem while freeing its container:

teploy sandbox stop 01JCV5ZK3Q7X9B2D4E6F8A0B1C --host prod

Stopped sandboxes are kept for 14 days by default. Bring the same sandbox back with a new deadline:

teploy sandbox resume 01JCV5ZK3Q7X9B2D4E6F8A0B1C --host prod --ttl 2h

Branch a new sandbox from a running or stopped sandbox's filesystem and settings, leaving the original untouched:

teploy sandbox fork 01JCV5ZK3Q7X9B2D4E6F8A0B1C --host prod

Destroy a sandbox when you are done (asks for confirmation unless --yes is passed):

teploy sandbox rm 01JCV5ZK3Q7X9B2D4E6F8A0B1C --host prod

If you want a sandbox to stop automatically instead of being destroyed when its TTL expires, create it with --on-expire stop.

Using a daemon set up another way

If teploy-sandbox was installed manually or by teploy-ship rather than teploy sandbox host, pass --addr and --token-file on any command:

teploy sandbox ls --host prod --addr 127.0.0.1:7439 --token-file /deployments/sandbox/token

--addr must be a loopback IP (127.0.0.1:7439 or [::1]:7439) because the engine speaks plain HTTP. Reaching a non-loopback address or hostname requires --allow-remote-addr and should only be used on a trusted private network.

Troubleshooting

When a command cannot reach the engine, it checks the server and tells you which case applies:

  • Engine not installed: prints teploy sandbox host <server>.
  • Service installed but not running: prints the systemctl commands to inspect and start it, along with recent log lines when readable.

Once connected to the engine, new and fork also check its driver and report if --driver vm is unavailable because the server runs the Docker driver (or if a server running the experimental VM driver requires --driver vm).