Sandboxes
How project sandboxes run in Docker, on Blaxel or on Runtime Cloud, what's inside them, and how to maintain them.
How project sandboxes run in Docker, on Blaxel or on Runtime Cloud, what's inside them, and how to maintain them.
Each project runs in its own sandbox. Locally that’s a Docker container made from the onedrop-sandbox image. In production it’s a microVM made from the same image, on Blaxel or Runtime Cloud.
The image is defined in docker/sandbox/:
ttyd, the web terminal behind the Shell tabstart.sh, which keeps three processes running: the app’s dev server (or a placeholder page), the host-rewriting proxy, and the terminalforwarder.mjs, which runs an agent task and streams its events back to OneDropfile-watcher.mjs (with inotify-tools), which start.sh keeps running. When files in /workspace are added, removed or renamed, it POSTs to a signed address the sandbox got when it was created (APP_FILES_CHANGED_URL), so the Files panel reloads its tree only after a change. It skips node_modules, .git, vendor, .cache, SQLite journals and editor swap files. Sandboxes made before it keep reloading the tree as the agent works, until they updatedb.php, which finds the app’s databases and runs the queries behind Tools → Databaseauth.php and guides/auth.md, behind Tools → Users & Auth: the tool that lists the app’s users and saves provider keys, and the guide the agent follows to add sign-ininstructions.md, the rules the agent follows (plain language, how to start a dev server, default stacks)Build or rebuild it with:
php artisan sandbox:build-image
Each container gets:
127.0.0.1 only: the proxy (preview) and the terminalonedrop.sandbox label, so you can find all sandboxesProjects that bring their own docker-compose.yml (see Run a project’s Docker Compose) need Docker inside their sandbox. Each provider has its own Docker inside sandboxes setting in Settings → Sandboxes.
| Provider | Setting | Notes |
|---|---|---|
| Docker | SANDBOX_DOCKER_NESTED: off, privileged or runtime | See below. |
| Runtime Cloud | RUNTIME_NESTED_DOCKER: off or on | Runtime sandboxes are VMs with their own disk, so Docker needs no privileged mode or extra volume. Raise Memory and Disk for real stacks: one with Mongo and Elasticsearch needs about 4 GB of memory and 20 GB of disk. |
| Blaxel | Not supported yet | Blaxel’s root filesystem is overlay, so Docker would fall back to its slow vfs storage, and Blaxel’s own API uses port 8080. |
For the Docker provider:
| Value | What it does |
|---|---|
off | No Docker in sandboxes (the default). |
privileged | Containers run with --privileged. For a local install only: a sandbox that runs privileged can reach the machine it runs on. OneDrop refuses it outside APP_ENV=local. |
runtime | For servers. Set Container runtime to one that makes Docker in a container safe, such as Sysbox (sysbox-runc). |
Each Docker sandbox gets its own volume at /var/lib/docker, deleted with the sandbox: Docker can’t unpack images onto a container’s own (overlay) filesystem. The sandbox starts Docker (/opt/onedrop/dockerd, through a sudo rule), raises vm.max_map_count for Elasticsearch where it can, and its socket belongs to the sandbox user, so the agent can use it.
Turning it on or off updates existing sandboxes, with their files, the next time their projects are opened.
Blaxel and Runtime pause idle sandboxes by themselves. Docker doesn’t, so the app does it: a Docker sandbox nobody has used for a minute is suspended with docker pause, as Runtime pauses its sandboxes after a minute. Its processes are frozen with their memory kept, and it uses no CPU.
An open workspace tab, the agent’s events and any network traffic to or from the container (such as its preview open in its own tab) count as use. It wakes by itself in well under a second, carrying on where it was, when its project is opened, while its workspace is open in a browser tab, when the gateway sends someone to it, and before any command the app runs in it. A sandbox whose agent is working, or whose project is published, is never suspended. Coming back to a workspace tab whose sandbox was asleep reloads its preview by itself, and so does a workspace left open and visible while it slept (the computer slept, say): the open tab wakes it within about 20 seconds. A workspace left open that nobody has touched for 15 minutes (no clicks, typing, scrolling or mouse movement) stops keeping its sandbox awake, so a forgotten window doesn’t keep it running; using the page again wakes it.
A paused sandbox still holds its memory, so one left suspended for 5 minutes is stopped (docker stop), freeing it. It starts again the same way, in a second or two, with its files; only its processes (the app’s dev server, an open Shell tab) start afresh. Change the wait with SANDBOX_DOCKER_STOP_AFTER_MINUTES, or set it to 0 to keep suspended sandboxes paused.
A container stopped outside the app (from Docker Desktop, or by a restart) starts again the same way. Each container keeps the host ports it was created with, so its preview and shell links still work after a restart.
Stopped sandboxes are exactly what docker system prune and docker container prune delete, so running either removes every idle sandbox. Their Docker-in-sandbox volumes stay behind, but their files go with them. When a project whose container is gone is opened, the app replaces it:
To free disk space without losing sandboxes, prune images instead (docker image prune), or run docker container prune --filter "label!=onedrop.sandbox" to skip them.
If a sandbox’s host folders under SANDBOX_DOCKER_STORAGE_PATH (its App Storage, or its user’s Claude sign-in) are deleted while it runs, the container can no longer write to them: a Claude sign-in says Login successful but doesn’t stick. The next time the sandbox is woken, the app makes the missing folders again and restarts the container so it picks them up. Its files and home folder are kept, and its preview reloads. Whatever was in a deleted folder is gone, so sign in to Claude again.
The sandbox:suspend-idle command does the suspending, every 15 seconds, from Laravel’s scheduler: composer run dev runs the scheduler locally, and the server install runs it as the drop-scheduler service. Change the wait with SANDBOX_DOCKER_IDLE_SECONDS, or set it to 0 to never suspend.
Blaxel runs each sandbox in its own microVM. OneDrop talks to its REST APIs, so the server needs no Docker.
In the Blaxel console, create an API key. Set it as BL_API_KEY, and your workspace name as BL_WORKSPACE, in your secret manager, with SANDBOX_PROVIDER=blaxel. Set SANDBOX_CALLBACK_URL to your public APP_URL, and leave SANDBOX_GATEWAY_DOMAIN empty.
Install the Blaxel CLI (bl), then run:
php artisan sandbox:build-image
With SANDBOX_PROVIDER=blaxel, this builds docker/sandbox on Blaxel with the steps in docker/sandbox/blaxel/ appended: Blaxel’s sandbox API and an entrypoint that starts it, then start.sh as the sandbox user. The Docker image is unchanged. Set BLAXEL_CLI if bl isn’t on the PATH. Run it again after changing docker/sandbox/; existing sandboxes then update themselves.
How it differs from Docker:
PORT=80 in every process, so OneDrop passes the app’s port as ONEDROP_PORT and sets PORT again for each command.bl.run. Each link carries a token, and OneDrop hands it only to people allowed to see the project. The first visit trades the token for a cookie. Tokens last 7 days, and OneDrop fetches new links at most once a day when someone opens the project.BLAXEL_MEMORY_MIB (4096 by default, the most a new account allows) also sets CPUs, one per 2048 MB. About half of it holds the sandbox’s files.php artisan sandbox:build-image builds on Runtime, php artisan sandbox:prune-images deletes older versions of the image (including ones from before OneDrop’s rename) that no running, paused or persistent sandbox came from. The current version and any newer build are kept. Run it with --dry-run to see what it would delete.To find or delete sandboxes by hand:
bl get sandboxes
bl delete sandbox <name>
Runtime Cloud runs each sandbox in its own Firecracker microVM. OneDrop talks to its HTTPS API, so the server needs no Docker.
Create a key at API keys and set it as RUNTIME_API_KEY in your secret manager, with SANDBOX_PROVIDER=runtime. Set SANDBOX_CALLBACK_URL to your public APP_URL, and leave SANDBOX_GATEWAY_DOMAIN empty.
php artisan sandbox:build-image
With SANDBOX_PROVIDER=runtime, this builds docker/sandbox on Runtime as onedrop-sandbox:latest. It needs Node.js 22.12 or later. Run it again after changing a base file in docker/sandbox/; existing sandboxes then update themselves.
To do this automatically, add a RUNTIME_API_KEY secret to the GitHub repository (and a RUNTIME_IMAGE variable if you don’t use onedrop-sandbox:latest). The runtime image workflow then rebuilds the image whenever a push to main changes docker/sandbox/, and never otherwise, because each build counts against the trial’s daily limit.
Sandboxes use the free trial until you set RUNTIME_FUNDING=paid. Add credit at billing before production traffic runs.
How it differs from Docker:
/home/sandbox/.onedrop-env, readable only by the sandbox user. start.sh and the Shell tab read it. They never appear in a command line.runtimehost.com. Each link carries a token, and OneDrop hands it only to people allowed to see the project. Tokens last 7 days, and OneDrop fetches new links at most once a day when someone opens the project. Browsers won’t show private Runtime links inside another site’s page, so with private links the Preview and Shell tabs only open in their own browser tab. With paid credit, set RUNTIME_PREVIEW_VISIBILITY=public to show them in the workspace: public links carry no token, so anyone who has one can open it.RUNTIME_PERSISTENT=true so leases renew.SANDBOX_WEB_WAIT_SECONDS (0 for no limit). Background jobs keep their longer timeouts.To find or stop sandboxes by hand, use the Runtime CLI with the same key:
npx withruntime sandbox ls
npx withruntime sandbox stop <id>
E2B runs each sandbox in its own Firecracker microVM, with Docker inside it (overlayfs on an ext4 disk). Use it as the fallback for projects that run their own Docker Compose stack, which Blaxel can’t run. OneDrop talks to its HTTPS API, so the server needs no Docker.
Create a key in the E2B dashboard and set it as E2B_API_KEY, or enter it in Settings → Sandboxes → E2B.
Saving E2B’s key in Settings → Sandboxes has E2B build the onedrop-sandbox template from the published sandbox image (ghcr.io/onedrop-io/onedrop-sandbox:latest), with start.sh already running, so a new sandbox starts in about 3 seconds. It takes about 2 minutes; E2B’s panel says when it’s ready (open it again to check), and E2B can’t be put first until then. To start a build from a terminal instead: SANDBOX_PROVIDER=e2b php artisan sandbox:build-image.
The image is the one the images workflow published from main, not your working copy of docker/sandbox/. After each new one, the sandbox image workflow tells OneDrop, which has E2B build again at your size. It proves it’s your repository’s workflow with a GitHub OIDC token, so there’s nothing to set up for it; set a repository variable ONEDROP_URL if your install isn’t at https://onedrop.io, and SANDBOX_IMAGES_REPOSITORY in OneDrop if your repository isn’t onedrop-io/onedrop.
In Settings → Sandboxes, turn E2B on. Put it first to move projects there, or second as the fallback: turning off the provider above it moves everything to it (Switch providers).
How it differs from Runtime:
E2B_IDLE_SECONDS), a sandbox pauses with its memory and running containers kept. The next visit or command wakes it in about a second. An open workspace and gateway visits put the pause off.A sandbox on E2B, Runtime Cloud or Blaxel runs in the cloud, so it can’t reach http://host.docker.internal:8000 to send the agent’s events back. When SANDBOX_CALLBACK_URL is a private address and cloudflared is installed (brew install cloudflared), composer run dev also runs php artisan sandbox:tunnel. That opens a free quick tunnel (no Cloudflare account), and cloud sandboxes report back through it. Sandboxes on Docker keep using SANDBOX_CALLBACK_URL.
ask, Drive and “Sign in with OneDrop”: no login, no pages./etc/onedrop-callback), so a running agent, the file watcher, ask and Drive keep reporting back. A sleeping sandbox gets it on its next agent run.For a stable address, set SANDBOX_CALLBACK_URL to a public one that reaches this machine (a named Cloudflare tunnel, or an ngrok static domain); then no quick tunnel starts.
Each sandbox keeps running on the provider it was created on, and sandboxes on Docker, Blaxel and Runtime Cloud can run side by side. Where projects run is set in Settings → Sandboxes: new projects go to the first provider that’s turned on and set up.
To move projects to another provider, change the toggles there. There’s no command to run:
Each sandbox that’s no longer where its project should run starts moving at once, in the queue. That includes projects, computers and tasks’ copies. The toast says how many are moving, and the Moves list on the same page shows each one: what it’s doing, why one failed (with Try again), and files recovered from a provider that had stopped answering (with Restore).
A move keeps the project’s files (uncommitted changes too), dependencies, App Storage and the sandbox user’s home folder, which holds the agent’s history and any database the agent set up. Where the files come from depends on whether the old sandbox answers within 20 seconds:
| Old sandbox | The new sandbox gets | The old sandbox |
|---|---|---|
| Answers | A fresh snapshot, taken once the agent’s turn ends | Deleted once the new one has every file |
| Doesn’t answer | The project’s latest snapshot, or its code backup without one | Kept, and checked on when you open Settings → Sandboxes, for 7 days |
| Doesn’t answer, nothing stored | Nothing: the move fails and the project stays where it is | Kept |
When a project comes back from an earlier snapshot, its chat says from when. If the old sandbox answers again later, its files are saved as a recovered snapshot (only if they’re newer than what the project got) and the old sandbox is deleted. An admin can then restore them from Settings → Sandboxes, which replaces whatever changed since the move, or dismiss them.
Moves are made of short queue jobs, each under a minute, so they run on Laravel Cloud’s Flex queues (90 seconds a job). Packing and unpacking files happens inside the sandboxes in the background, and each sandbox calls OneDrop when it’s done, so nothing waits or checks back (a safety check after 15 and 30 minutes catches a call that never arrives). A typical project moves in about a minute. Messages sent to the agent while its sandbox moves start in the new sandbox once it’s ready. A move that’s still not done after an hour is given up, and the project stays on its old sandbox.
Build the image on the new provider before moving anything to it (php artisan sandbox:build-image). Moves need a snapshot disk both providers can reach, which means a bucket for remote providers. With a local disk and a remote provider, the files are copied through the platform instead, which can take longer than a Flex queue job allows.
Deleting a project, or the account that owns it, removes its sandbox from the provider it’s on, even if that’s no longer the configured one.
SANDBOX_PROVIDER in .env only applies until providers are saved in Settings. To move every project now from a terminal, or just one, and wait for it:
php artisan sandbox:update
php artisan sandbox:update 12
The agent creates an executable /workspace/.onedrop/dev script that starts the app’s dev server on $PORT, then runs /opt/onedrop/restart. The container’s loop starts that script instead of the placeholder. Output goes to /tmp/onedrop-server.log, which the Console tab shows.
The sandbox’s proxy (docker/sandbox/host-proxy.mjs) records the app’s errors in /workspace/.onedrop/errors.log: 5xx responses, the app not answering, and browser errors. It adds a small script, /__onedrop/errors.js, to HTML pages served on the preview address only. That script reports browser errors to /__onedrop/error and to the app builder around the preview. Reports are only accepted from the preview address, which sits behind the app builder’s sign-in. See When the app hits an error.
The guides the agent follows, the tools behind panels like Database and Growth, and the proxy all ship in the sandbox image, in /opt/onedrop. Existing sandboxes pick up changes to them on their own, while nobody is using them:
/opt/onedrop, such as guides, scripts and the proxy) are copied into the running sandbox, only the ones that changed. Processes that load them once, like the proxy, restart in about a second. Nothing else in the sandbox changes, and you don’t need to rebuild the image for these.Dockerfile, start.sh, dockerd, shell-keys.js) need a rebuilt image (php artisan sandbox:build-image; the server deploy script does this when docker/sandbox/ changes). Each sandbox then moves to a new one from that image, keeping its files.Updates run once a project has gone unused for 10 minutes, then the sandbox is suspended again. A new sandbox is made the same way as in a provider switch: short queue jobs, the files carried by a fresh snapshot. They never run while someone has the project open or its agent is working, and a sandbox nobody uses isn’t woken for one; it’s updated after its next use. Before each agent run, changed tool files are copied in first (a second or two) so the agent has the current guides. The preview shows Updating sandbox… only while a new sandbox is being made.
On Blaxel, tool files can’t be copied in (its sandbox API can’t write /opt/onedrop), so a rebuilt image moves each sandbox to a new one instead.
An update keeps the app’s files (/workspace), App Storage buckets, and the sandbox user’s home folder (/home/sandbox), which holds the agent’s conversation history and anything the agent installed there, such as a local database. Shell settings in the home folder stay as they were rather than taking the image’s. The app’s processes are paused while the files are copied, so a database is copied in a consistent state. The app restarts, and published projects are published again. Only one update runs per project at a time.
To update every sandbox now, or just one project:
php artisan sandbox:update
php artisan sandbox:update 12
Projects the agent is working on are skipped; they update before their next run. Each sandbox the command updates is suspended once it’s done (memory kept), and wakes on the project’s next visit, so a batch of updates doesn’t keep every new sandbox running at once.
To replace a sandbox even when it’s up to date (for example, one that’s broken):
php artisan sandbox:recreate 12 --keep-files
--keep-files gives the new sandbox the app (/workspace), its dependencies, App Storage and the sandbox user’s home folder (with the agent’s conversation history), from a fresh snapshot where it can, or from the latest one if the old sandbox is gone. Without it, the project’s code is restored from its backup, and App Storage and the agent’s conversation history start empty. Published projects are published again automatically.
After every agent turn, /opt/onedrop/checkpoint saves a private checkpoint of every file (the forwarder runs it, whichever agent ran the turn). Checkpoints are commits on refs/onedrop/checkpoints, made through their own index, so the branch, its history and what the user staged are untouched, and pushes never send them. Edits made outside the agent are saved as their own checkpoint before the next turn and before each backup. When the project’s Commit after each agent turn switch is on, the script then commits everything to the branch too (the runner passes ONEDROP_COMMIT_TURNS=0 when it’s off). A BackupProject job copies the whole history, checkpoints included, out of the sandbox as a verified git bundle. Bundles are stored at project-backups/<project id>/repo.bundle on the filesystem disk named by SANDBOX_BACKUP_DISK, or the app’s default disk (FILESYSTEM_DISK) when that isn’t set. The sandbox never gets credentials for that disk: the platform copies the bundle out through the provider.
Checkpoints never include node_modules, vendor, .cache or .env files (except .env.example), and a repository in the middle of a merge or rebase is left alone. Backups hold code and its history only; App Storage buckets and databases outside git aren’t in them.
When a sandbox is replaced without its files, the backup is cloned into the new one, with every branch, work that wasn’t committed is put back from the newest checkpoint as uncommitted changes, and the app starts. That covers a sandbox that’s broken or gone, including one on a provider that stopped answering and a project with no snapshot yet: a provider switch falls back to the backup by itself. Deleting a project deletes its backup.
In production, keep backups on object storage so they outlive the server: an s3 disk in config/filesystems.php, set as FILESYSTEM_DISK or SANDBOX_BACKUP_DISK. On Laravel Cloud, attach a bucket to the environment as its default disk.
Besides the git backup, OneDrop keeps each project’s whole state outside its sandbox, so a lost sandbox, a failed update or a provider that goes away never costs files. A snapshot has four layers:
| Layer | What’s in it |
|---|---|
workspace | /workspace with uncommitted changes and .git, without dependency folders |
deps | Every node_modules folder and the top-level vendor, stored again only when a lockfile changes |
home | /home/sandbox without caches: the agent’s history, and a database or tools the agent set up there |
storage | App Storage |
Snapshots are taken after every agent turn, once a project has gone unused for 10 minutes (so work done only in the Shell or by the app itself is kept too), before an update or a move gives a project a new sandbox, and daily at 04:00 for projects used that day (php artisan sandbox:snapshot). The daily run skips a project unused since its latest snapshot, so it doesn’t wake a sleeping sandbox for nothing, and puts a suspended sandbox it does wake back to sleep. Each layer is fingerprinted in the sandbox first, and only layers that changed are packed and stored again. With a bucket, the sandbox packs and uploads them in the background and calls OneDrop when it’s done, so no job waits on it however large the project. The app’s processes are frozen while the stateful layers are packed (usually well under a second), so a database is captured in a consistent state. Layers are compressed with zstd, or gzip on images without it.
Updates and moves restore the new sandbox from a snapshot instead of copying files through the platform. A sandbox that’s gone, or doesn’t answer, gets its latest snapshot back with php artisan sandbox:recreate <project> --keep-files; one that doesn’t answer is kept and checked on, as in a provider switch.
Snapshots go to the disk named by SANDBOX_SNAPSHOT_DISK, or the backup disk when that isn’t set:
SANDBOX_SNAPSHOT_DISK to its disk name.docker cp, without going through HTTP. Remote sandboxes (Runtime, Blaxel) need a bucket; with a local disk they take no snapshots and updates copy files through the platform as before.A local disk keeps snapshots on the same disk as the sandboxes. They cover a broken sandbox or a failed update, not losing the server. Point SANDBOX_SNAPSHOT_DISK at an off-site bucket (Backblaze B2, Cloudflare R2, Hetzner Object Storage) for real backups.
OneDrop keeps the latest 10 snapshots of each project and the newest of each of the last 7 days, plus recovered snapshots for 30 days, and deletes stored layers no kept snapshot uses. To list a project’s snapshots, or give it a new sandbox from one of them:
php artisan sandbox:restore 12 --list
php artisan sandbox:restore 12 41
Deleting a project deletes its snapshots.
Nothing removes old containers automatically yet. To remove every sandbox and publish container:
docker rm -f $(docker ps -aq --filter label=onedrop.sandbox) $(docker ps -aq --filter label=onedrop.sandbox.publisher)
The normal test suite uses a fake provider. To test against real containers:
RUN_DOCKER_TESTS=1 vendor/bin/pest tests/Integration
Each person’s computer is a sandbox too, on the same provider and image as projects (SANDBOX_PROVIDER), started with ONEDROP_DESKTOP=1 so it runs a desktop (TigerVNC, Openbox, Chromium) shown through the sandbox’s own proxy at /__onedrop/desktop/. It sleeps when unused and is kept up to date like any sandbox, so it costs what a project’s sandbox costs while someone uses it. Turn them off for the install with COMPUTERS_ENABLED=false.
Every sandbox, computer or project, keeps a copy of Drive in step with drive.mjs, which only asks for changes while the sandbox is in use, so it doesn’t keep idle sandboxes awake.