> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boat.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# What a snapshot saves

> Which folders a snapshot saves and which it does not. Docker containers, images and build cache, tool caches, /tmp and the IP address after a resume.

A snapshot saves the parts of the disk that you changed. It does not save the operating system that every machine already has.

## Saved and not saved

> [card] Saved
>
> `/home/user`: your code, files and settings
>
> Every other home folder under `/home`, for example a second Linux user
>
> Folders that you create at `/`, for example `/code` or `/data`
>
> Docker **named volumes** (`/var/lib/docker/volumes`)
>
> Your Docker **containers** and every tagged Docker **image**, used by a container or not ([read more](#docker))
>
> **Your changes** in `/etc`, `/usr`, `/opt`, `/root`, `/srv` and `/var`, with their owners and permissions. This means installed packages, systemd services, system settings, cron tables and the data of databases that you install with apt.

> [card] Not saved
>
> The operating system and the tools that come with every machine
>
> The identity of the machine: hostname, IP address, network settings, [SSH host keys](https://docs.boat.dev/ssh-access.md#verify-the-host-key)
>
> `/tmp` and `/var/tmp`, `/var/cache`, the journal logs (`/var/log/journal`) and Docker internals other than volumes. Put files that must survive a stop in `/home/user` or in a folder that you create at `/`.
>
> Your cache folder `~/.cache`, except Playwright browsers and the Deno cache ([read more](#tool-caches))
>
> Running programs, memory and open ports. A resume within 10 minutes of a stop usually gets them back on the same machine ([read more](https://docs.boat.dev/snapshots/stop.md#resume-within-10-minutes))
>
> The Docker **build cache**, and untagged `<none>` images ([read more](#docker))

The IP address changes at every resume and fork. To reach a port at a fixed address, use a [public URL](https://docs.boat.dev/hosting).

### Keep a hostname

A snapshot does not save `/etc/hostname`, so the hostname changes at every resume and fork. To keep a hostname, set it from an enabled systemd service. Enabled services start again after each resume and fork.

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
sudo tee /etc/systemd/system/set-hostname.service >/dev/null <<'EOF'
[Unit]
Description=Set a fixed hostname

[Service]
Type=oneshot
ExecStart=/usr/bin/hostnamectl set-hostname my-sandbox

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now set-hostname.service
```

To name a sandbox in boat, set its `name` instead. The hostname is not used for that.

## Deleted files stay deleted

A deletion is a change, so the snapshot saves it too. For example, remove a coding agent that comes with the machine:

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
sudo rm -rf /opt/kimi-code /usr/local/bin/kimi
sudo npm uninstall -g @openai/codex
```

The agent stays gone after every resume, fork and deploy from a saved snapshot. The same is true for an apt package that you remove.

If you install your own copy of a tool, your copy is used, not the one that comes with the machine.

## A restore is like a reboot

When a sandbox comes back from a snapshot, it is like a server that restarts.

* Your files, packages and system settings are there.
* **Systemd services that you enabled start again by themselves.**
* **Docker containers that ran start again by themselves.**
* Programs that you started by hand are not running. Start them again, or make them a service.
* Snap packages are reinstalled.

Services and containers start a few seconds after the sandbox is `ready`. Read [Readiness and resume speed](https://docs.boat.dev/readiness.md).

To keep a program running across stops, read [Keep a sandbox running](https://docs.boat.dev/long-running-tasks.md).

## Docker

Docker and BuildKit are installed. This is what a resume, a fork or a deploy from a saved snapshot gets back:

| Docker part | After a resume or fork |
| - | - |
| Named volumes | Saved. All data comes back |
| Containers | boat creates each container again with its settings. Containers that ran start again. A Compose project comes back with `docker compose up` |
| Images that a container uses, from a registry | boat pulls the exact same image again, by digest |
| Images that a container uses, built in the sandbox | Saved in the snapshot, with their tags |
| Other tagged images, also images that no container uses | Saved in the snapshot, with their tags |
| Untagged `<none>` images | Not saved |
| Build cache | Not saved. The first build starts from zero |

A snapshot saves these images at the moment you take it. Do not stop Docker before `boat snapshot`.

After a resume reaches `ready`, images and containers load in the background. They appear about 2 seconds later. Read [Readiness and resume speed](https://docs.boat.dev/readiness.md).

boat pulls the registry images that a container uses from their registry at each resume. A private registry needs its login in the sandbox.

### Docker builds

While a sandbox runs, `docker build` uses its layer cache as usual. A rebuild with no change takes less than one second. The cache is in `/var/lib/docker`, and a snapshot does not save it.

To keep the build cache, save it in your home folder:

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
docker buildx build \
  --cache-to type=local,dest=$HOME/.buildcache,mode=max \
  --cache-from type=local,src=$HOME/.buildcache \
  --load -t myapp .
```

We measured this on a Node app with a slow dependency install:

| Build | Time |
| - | - |
| First build, no cache | 38 s |
| Rebuild on the same machine | 0.4 s |
| Rebuild on a fork, with the saved cache | 8 s |

## Tool caches

A snapshot does not save `~/.cache`. Tools that download files into it download them again after a resume or a fork.

Two folders in `~/.cache` are saved:

* `~/.cache/ms-playwright`: the Playwright browsers. `npx playwright install` puts them there by default.
* `~/.cache/deno`: the Deno cache.

To keep the cache of another tool, point that tool at a folder outside `~/.cache`.

## Leave files out with `.boatignore`

Build output and dependency folders slow down every restore, and you can make them again. To leave them out of snapshots, write a `.boatignore` file. The next snapshot uses it.

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
cd ~/myapp
printf 'node_modules/\n.next/\n' > .boatignore
```

* It uses the same rules as `.gitignore`.
* Its rules apply to the folder that it is in. A `.boatignore` in a repo applies to that repo. A `.boatignore` in your home folder applies to the whole sandbox.
* boat looks for it up to six folders below your home folder. It does not look inside `node_modules`, `.next`, `target` or `vendor`.
* Put the file at the top of the folder that you want to leave out, not inside it.
* `.git` is always saved, because you cannot make it again.
* boat also reads the old names `.boxignore` and `.oneignore`. If a folder has more than one, `.boatignore` wins.

**boat does not read your `.gitignore`.** A `.gitignore` lists files that you do not commit. That is not the same as files that you can lose. Also, a tool that you install with `git clone` has its own `.gitignore`. For example, the `.gitignore` of `~/.nvm` lists every Node version that you install.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.