Chapters

Chapter 5

Sandboxes and their lifecycle

A sandbox is one Linux virtual machine with its own disks.

On this page
  1. Concepts
  2. The states
  3. Renaming a sandbox
  4. The quickest way: Quick add and doz new
  5. Create and start — in the terminal
  6. Create and start — in the dashboard
  7. See what you have
  8. Saved screens
  9. Boot logs
  10. The daemon
  11. Time zone
  12. Settings
  13. Limits
  14. Troubleshooting

A sandbox is one Linux virtual machine with its own disks. This page covers making one, the states it can be in — running, paused, asleep, hibernated, shut down — and moving between them, and the background daemon that runs them all.

A sandbox can also be adopted into a workspace, with other agents, a room and a brief — see Workspaces; adopting it changes nothing of the sandbox itself. A workspace's doz workspace sleep hibernates its sandboxes (the same as doz hibernate, all at once) and wake wakes them; finish shuts them down, keeping their disks — a workspace never removes a sandbox unless you say so (--remove-sandboxes, and never one you adopted).

A Sandbox is one of three places an agent can run; the other two are fenced and unfenced sessions on this Mac. Where an agent runs: the three choices compares them (what each reaches, its memory, its start time, when to pick it).

Concepts#

  • Name. 1–40 characters of a-z 0-9 -, unique in the store.

  • Image. What the sandbox starts from (Claude Code, pi, a plain shell, a saved disk…). See Images and bases.

  • Three kinds of storage, each kept differently:

    what's on itkept through
    the root diskthe system and anything installed or written outside the next twoshutdown; gone with reset (back to the image) and rm
    the state disk (agent images)the agent's own settings, logins and history (~/.claude, ~/.pi/agent)shutdown and reset; gone with rm
    the folderyour Mac folder, shared live — it appears inside the sandbox at /workspaceeverything — it's on your Mac
  • Isolated. A sandbox with no shared folder: /workspace is a folder on its own disk, and nothing on your Mac is shared. doz ls shows isolated, and the agent is told.

  • Sessions. The terminal programs running inside (a shell, claude, pi). They survive pause, sleep and hibernate. See Terminals and sessions.

  • The daemon. One background doz process per store. It owns every running Sandbox, the network proxy and the credentials. The first command that needs it starts it, and it keeps running (daemon.always_on), so you normally never think about it.

The states#

The states of a sandbox. doz create makes it, off. doz start boots it: booting, then running (or failed; doz start tries again). From running: doz pause and doz resume (paused: frozen, memory kept, back in about 1 ms); doz sleep and doz wake (asleep: frozen and saved to disk, memory kept, back in about 0.3 s); doz hibernate and doz wake (hibernated: saved to disk, memory given back, back in about 0.3 s); doz shutdown or doz reset (a fresh disk) back to off (powered off, disks kept, programs ended). doz rm removes it.
Show as text
mermaid
stateDiagram-v2
    direction LR
    [*] --> off: doz create
    off --> booting: doz start
    booting --> running
    booting --> failed
    failed --> booting: doz start
    running --> paused: doz pause
    paused --> running: doz resume
    running --> asleep: doz sleep
    asleep --> running: doz wake
    running --> hibernated: doz hibernate
    hibernated --> running: doz wake
    running --> off: doz shutdown
    running --> off: doz reset (a fresh disk)
    off --> [*]: doz rm

    note right of paused: frozen · memory kept · back in ~1 ms
    note right of asleep: frozen and saved to disk · memory kept · back in ~0.3 s
    note right of hibernated: saved to disk · memory given back · back in ~0.3 s
    note left of off: powered off · disks kept · programs ended

doz ls and the dashboard show which of these states each sandbox is in. doz up also wakes an asleep or hibernated sandbox and resumes a paused one, so it's the one command to remember.

commandwhat happenstypical timememoryprograms
doz start NAMEboots (or wakes it if asleep, resumes it if paused)~0.4 s (a first start may prepare the image)used as neededstart fresh
doz pause NAME · doz resume NAMEthe CPU stops~1 mskeptfrozen, then carry on
doz sleep NAME · doz wake NAMEpaused and saved to disk — survives a crash of the daemon~0.3 skeptcarry on
doz hibernate NAME · doz wake NAMEsaved to disk, then the Sandbox stops~0.35 s / ~0.3 sgiven backcarry on: same processes, same screens
doz shutdown NAMEa cold stop; the disks are keptgiven backend
doz down NAMEthe opposite of up: hibernate (--sleep: sleep; --shutdown: shut down)as thoseas thoseas those
doz reset NAMEshut down and go back to a fresh copy of the image (the state disk and restore points stay)end
doz rm NAMEremove the sandbox and everything it has on diskend

start has an alias, cold-boot; pause has suspend.

doz down NAME puts a sandbox away when you are done for now: it hibernates it — nothing kept in memory, its sessions come back where they were with doz up (in its project folder), doz attach or doz wake. --sleep keeps its memory for an even quicker wake; --shutdown is a cold stop, asked first as shutdown is (-y skips the question).

The folder Dozable made goes with it. When a sandbox's folder did not exist and Dozable made it (doz new, New sandbox and Quick add in the dashboard, doz try, a --folder that was not there yet), doz rm — and the dashboard's Remove… — removes that folder too while it is empty. When it holds files, doz rm asks (the default keeps it and says where); off a terminal and in the dashboard it is kept. A folder that was there before is never touched, and neither is the folder of a duplicate.

shutdown, reset and rm ask first. --yes skips the question; without a terminal and without --yes they refuse, so a script can't destroy something by accident. The question names what you asked for — and checks it exists — before you answer.

Renaming a sandbox#

doz rename NAME NEW gives a sandbox another name. It is the same sandbox: its disks, restore points, folder, account, network, settings and kept terminal layout come along — only the name changes (its hostname inside follows at the next start). Nothing is lost, so it asks nothing.

bash
doz shutdown demo        # renaming needs it shut down (Shut down keeps its disk)
doz rename demo website
doz start website

It refuses while the sandbox runs, sleeps, hibernates or is busy — shut it down first — and refuses a name that is already taken or is not 1–40 characters of a-z, 0-9 and -. Its folder on your Mac keeps its own name and place — Dozable never moves your files. Disks saved from it keep saying which sandbox they came from, and past numbers on the Metrics page stay under the old name.

In the dashboard: Rename… in a sandbox's ⋯ menu — in the sidebar (on the sandbox's line) and on its page's toolbar. A sandbox that isn't shut down is shut down first: the dialog says so, and its button reads Shut down and rename.

A program started less than three seconds before a hibernate gets the rest of those three seconds first, so a program in the middle of starting up isn't frozen at a bad moment.

The quickest way: Quick add and doz new#

One click in the dashboard, or one command, makes a sandbox with every default and puts you in it:

  • the image is the setting defaults.image (onboarding sets it to the image you chose);
  • the name is the image's — claude-sandbox, pi-sandbox, lab-sandbox — or the next free one (claude-sandbox-2, …) when a sandbox has that name, or its folder already has something in it;
  • its folder is a folder of its own in your projects folder, the setting defaults.projects_dir (~/doz-workspaces unless you change it): ~/doz-workspaces/claude-sandbox, made for it;
  • the account and what the agent can do are the defaults.

In the dashboard, Sandboxes › Quick add (or the + beside Sandboxes in the sidebar). The sandbox is made and started at once; its page opens with the boot in a terminal, which then becomes the sandbox's own session. A note says what it chose.

Quick add: the new sandbox's page, its terminal live
Quick add: the new sandbox's page, its terminal live

In a terminal:

sh
doz new

It prints what it chose — claude-sandbox-2 · claude-code · ~/doz-workspaces/claude-sandbox-2 — then creates it, starts it and attaches you to its session (Ctrl-] twice detaches; it keeps running). Each option changes just that one thing:

optionwhat it does
--imageAnother image than defaults.image.
--nameYour own name (refused if a sandbox has it).
--isolatedShare no folder.
-d · --detachCreate and start it, but don't attach.
--jsonAnswer {name, image, folder, phase, session, milliseconds} instead of attaching.

When one click can't decide. Some things need your choice first: pi needs an Anthropic API key, and an image an older doz prepared can be used as it is or rebuilt. Then Quick add opens the New sandbox form instead — filled in with its choices, and the requirement said at the top — and doz new asks on a terminal, as doz create does (off a terminal it says what to do and makes nothing). doz new uses the store's default account: doz account default NAME makes an API-key account the default.

The projects folder. Change it in Settings › New sandboxes › projects_dir › Choose… (your Mac's own folder picker), or doz config set defaults.projects_dir ~/code/sandboxes. New sandboxes from Quick add, New sandbox and doz new use it; existing ones keep their folders.

Create and start — in the terminal#

sh
doz create my-box --image lab --isolated            # made, and off
doz start my-box
doz create my-app --image claude-code --folder ~/code/my-app --start
doz create my-pi --image pi --folder ~/code/my-pi --prepare   # made and off, its image ready
doz up my-app                                        # create if missing, start or wake, attach
optionwhat it does
--imagelab, claude-code, pi, a base × agent image, or a saved disk (doz image save). Or --agent with --base / --dockerfile (Images and bases).
--folder DIRShare this Mac folder at /workspace. Made if it doesn't exist; refused for your home folder itself, system locations and the store.
--isolatedShare nothing (the default without --folder; this says it on purpose).
--cpus · --memoryVirtual CPUs (default 2) · RAM (2G, 512M; default 1 GiB for lab, 2 GiB for an agent image).
--network · --allowWhat the agent may reach (What the agent can do).
--accountWhich Claude account it uses (Agents and accounts).
--startStart it straight away.
--preparePrepare its image now — download and bake it once, with its progress — so the first start does not wait; the sandbox stays off. If that image is already being prepared, it joins that preparation. Ctrl-C stops watching; the preparation goes on (doz onboard --status follows it).
--rebuild · --use-currentWhen the image is out of date: rebuild it first, or use it as it is.

doz up is the everyday command, like vagrant up or docker compose up: create if missing, start or wake, then attach to the image's own session (claude, pi, or a shell called shell). -d does all that without attaching. On an existing sandbox, create options are ignored (it says so).

Create and start — in the dashboard#

  1. Sandboxes › New sandbox — a wizard, step by step: the project folder (a new one in your projects folder, or one you have), the Agent and the Base (or a Saved disk), the account, access (GitHub, SSH agent), what the agent can do, CPUs and memory, the bridges, and the session. Each step is filled in from your settings; Skip to review keeps the rest.
  2. Review shows the doz_project.yaml it writes into the folder; Write and create writes it, makes the sandbox from it, starts it and opens it with the boot in a terminal. See Projects.
  3. Or One-page form (in the wizard, top right): everything on one page, a Shared folder or Isolated, and no project file. Create makes it off; Start boots it: the terminal area shows the image's build while there is one, then the Console tab (the boot as it happens), then the agent's own tab once it has drawn its screen. With the setting ui.boot_view_on_start on, the page stays on Console and marks the agent's tab instead of switching to it.
New sandbox
New sandbox

Each sandbox has an entry under Sandboxes in the sidebar, with a dot in its state's colour (filled while it holds memory, a ring when it holds none, a square when it failed). Its page has the lifecycle buttons across the top — Start, Pause, Resume, Sleep, Hibernate, Wake, Shut down — showing only those that make sense in its state, the one that brings it back first; Reset… and Remove… are under ⋯. Reset and Remove ask you to tick a box first; Shut down asks with a plain confirmation ("Don't ask again" sets ui.confirm_shutdown to false).

See what you have#

sh
doz ls                  # every sandbox: image, state, RAM held, disk, sessions, network
doz inspect my-app      # everything about one, as JSON
doz sessions my-app     # its terminal sessions

RAM held is what the Sandbox costs your Mac right now: its allocation, less what it handed back after a wake. It shows — for a sandbox that is off or hibernated. Looking never starts a daemon: with none running, these commands read the store directly.

Saved screens#

Before a sandbox pauses, sleeps or hibernates, Dozable saves the screen of each of its sessions — and every daemon.screen_capture_minutes (5) while it runs, for sessions that printed something since. So you can see what a sleeping sandbox was doing without waking it:

sh
doz sessions my-app                     # listed from their saved screens while it sleeps
doz sessions my-app --screen claude     # that session's last screen, as text

In the dashboard, a sleeping sandbox's page shows each session's saved screen, read-only (you can select and copy from it), with "press any key to wake". Saved screens exist only while you can wake the sandbox: shutdown, reset and remove delete them.

A hibernated sandbox's saved screens
A hibernated sandbox's saved screens

Boot logs#

Every boot of a sandbox — each start, each wake, a recovery after a crash — is kept: Dozable's timed steps as the boot view showed them, and the Linux kernel's own messages.

sh
doz console my-app --list               # the kept boots: when, what, how long, ✓ or ✕
doz console my-app --steps              # the latest boot's steps, then its kernel console
doz console my-app --boot 2             # the one before
doz console my-app --follow             # watch the console live as it boots

In the dashboard: ⋯ › Boot log on the sandbox's page (it works in any state; nothing is woken).

A kept boot
A kept boot

The daemon#

sh
doz daemon status          # is one running, and what does it hold? (never starts one)
doz daemon stop            # hibernate everything that runs, then stop the daemon
doz events               # follow what the daemon does, live (Ctrl-C stops)
doz events my-app        # only this sandbox
  • Always on. The daemon keeps running with nothing open (daemon.always_on, on by default; doz daemon status says so). When a new doz is installed, it replaces itself with the new version once nothing is running and nobody is attached — no command needed.
  • Idle exit, with doz config set daemon.always_on off: the daemon exits after daemon.idle_timeout_minutes with nothing running, paused or asleep and nobody attached (default 5; 0 disables it — and is warned, since the daemon then never switches off by idling). While daemon.always_on is on, the timeout has no effect. The next command starts a new one. A daemon started over ssh always exits after 5 minutes idle.
  • doz daemon stop shows each sandbox as it hibernates, then a summary. Everything wakes on the next wake, attach, up or exec, sessions and all.
  • If the daemon crashes, the next command starts a new one. Sleeping sandboxes come back with their sessions; hibernated ones are untouched. Ones that were running are marked as having died with the daemon (doz ls), and their disk is checked at the next start.
  • Logs are in <store>/daemon.log. doz metrics shows how long each kind of action takes.

Time zone#

A sandbox follows your Mac's time zone, read again at every start and wake — so a sandbox that slept while you travelled wakes in your new zone. The agent is told its time zone too. To pin one: doz config set sandbox.timezone Australia/Sydney.

The rest of Dozable's set-up inside the sandbox is put back at every start and wake too: apt never stops to ask a question, the sandbox's own name resolves, the agent's sudo follows its setting, and links open on your Mac. So a sandbox that only ever sleeps or hibernates and wakes still gets what a newer doz fixes, without a restart.

Settings#

keydefaultwhat it does
defaults.cpus2CPUs of a new sandbox (--cpus).
images.lab.memory_mib · recipes.anthropic.claude-code.memory_mib · recipes.earendil-works.pi.memory_mib1024 · 2048 · 2048Memory of a new sandbox of each image (--memory); other images follow the one they're based on.
defaults.projects_dir~/doz-workspacesYour projects folder: where Quick add, doz new and the dashboard's New sandbox make a new sandbox's own folder (<projects_dir>/NAME). Settings › Choose… picks it.
sandbox.timezonemacmac (follow this Mac) or a zone like Australia/Sydney. Applies at each start or wake.
daemon.always_ontrueKeep the daemon running with nothing open ($DOZ_DAEMON_ALWAYS_ON).
daemon.idle_timeout_minutes5With daemon.always_on off: minutes with nothing running before the daemon exits; 0 disables it ($DOZ_DAEMON_IDLE).
daemon.screen_capture_minutes5How often a running sandbox's changed screens are saved; 0 = only at pause, sleep and hibernate.
daemon.boot_logs_kept5Boots kept per sandbox (1–50).
ui.boot_view_on_startfalseAfter the dashboard's Start, stay on the Console tab rather than switch to the agent's tab.
ui.confirm_shutdowntrueThe dashboard's Shut down asks first.

Limits#

  • Memory is reserved up to the sandbox's allocation while it runs; hibernate gives it all back.
  • A snapshot (sleep, hibernate) can't be moved to another Mac: it is encrypted with a key specific to this Mac.
  • Nothing pauses or sleeps a sandbox by itself yet; you (or a script) decide.

Troubleshooting#

symptomwhat to do
The first start is slowIt's preparing the image, once per store. doz onboard or doz image bake NAME does it ahead of time; -v shows the steps.
A start or wake faileddoz console NAME --list, then doz console NAME --steps: the failing step is marked ✕, with why.
A wake fails again and againdoz daemon stop, then wake again (a failed wake keeps its snapshot). Last resort: doz shutdown NAME then doz start NAME — programs end, the disks are kept. For Claude Code, claude --continue picks the conversation back up.
A sandbox shows as diedThe daemon crashed while it ran. doz start NAME checks its disk and boots it.
"not possible in this phase"The action doesn't fit the sandbox's state (e.g. resume on one that isn't paused). doz ls shows its state.

Edit this page on GitHub · Chapter 5 of 50