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

# VM instances

> Run Docker, Kubernetes, databases, and Android emulators on a full virtual machine.

A `vm` instance is a full Linux virtual machine with its own kernel and KVM hardware
virtualization. It uses the same API keys, endpoints, URLs, and prepaid wallet as a default
instance. VM compute has its own rate, listed below.

Reach for it when your workload needs the kernel itself:

* **Docker, Compose, and buildx.** Build and run containers, including Docker-in-Docker workloads
  and containers that need privileged mode or their own networks.
* **Kubernetes.** k3s runs with its node Ready and pod networking working.
* **Databases.** Postgres, MySQL, Redis, anything with its own storage engine.
* **Android emulators.** `/dev/kvm` is present inside the machine, so an AVD boots with hardware
  acceleration instead of crawling. The `agent37-android` template has one installed and
  running already; see [Host an Android phone](https://www.agent37.com/docs/agents-api/android.md).
* **Mounted storage.** Mount an S3 bucket as a folder; see
  [Mount an S3 bucket](https://www.agent37.com/docs/agents-api/mount-s3.md).

A default instance is the right choice for everything else, and it starts faster.

VM instances run in every [region](https://www.agent37.com/docs/agents-api/instances/create.md#request-body): `us`, `eu`
(France or the UK), and `ap-south` (India, Mumbai). Outside the US they are the *only* type available, so
a create in `eu` or `ap-south` has to send `"type": "vm"`.

## Create one

```bash curl theme={null}
curl -X POST https://api.agent37.com/v1/instances \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "template": "agent37-ubuntu",
    "type": "vm",
    "resources": { "cpu": 4, "memory": 8, "disk": 20 }
  }'
```

`agent37-ubuntu` is Ubuntu 26.04 with Docker, Compose, and buildx installed and `dockerd` already
running, plus an XFCE desktop with Firefox in the browser. It is built for this type, so it only
runs as a `vm` and a create without `"type": "vm"` is a `400`.

[`agent37-android`](https://www.agent37.com/docs/agents-api/android) is a separate VM image with the Android SDK, an AVD,
ADB, and a screen on port `6901`. It does not bundle Ubuntu's Docker daemon or XFCE desktop.

Your own [custom image](https://www.agent37.com/docs/agents-api/custom-image.md) works too: pass `"type": "vm"` with any template.
Two things to know first:

* **A container runtime inside the machine must keep its data on your billed disk.** The writable
  root is an overlay, and pulling an image onto one fails. Point Docker at `$HOME` with
  `dockerd --data-root "$HOME/docker"` (or `/etc/docker/daemon.json`), and k3s with
  `--data-dir "$HOME/k3s"`. `agent37-ubuntu` already does this.
* **Your entrypoint is PID 1, and there is no init system.** An image whose entrypoint *is*
  systemd is not supported, the same as on Docker. Run your processes from your entrypoint, or
  install them and start them over [SSH](https://www.agent37.com/docs/agents-api/ssh.md).

## Run Docker inside the VM

After create returns, run Docker through [exec](https://www.agent37.com/docs/agents-api/exec.md) or [SSH](https://www.agent37.com/docs/agents-api/ssh.md):

```bash curl theme={null}
curl -X POST https://sandbox.agent37.app/v1/instances/ab12cd34ef/exec \
  -H "X-Agent37-Key: sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "command": "docker run --rm hello-world && docker compose version && docker buildx version" }'
```

Check the response's `exit_code` and `stdout`. Your existing tooling can keep calling
`docker run` and `docker compose` inside this machine. Containers share the VM's purchased
CPU, memory, and disk. Publish a container's HTTP port onto the VM with `docker run -p`, then
reach it at `https://{id}-{port}.agent37.app` with your workspace key.

Docker-in-Docker also works: a privileged `docker:dind` container can run its own daemon.
Bind its `/var/lib/docker` to a directory under `$HOME`, just as the outer daemon keeps its
data at `$HOME/docker`. The default gVisor instance type cannot run a Docker daemon.

## Getting in

`agent37-ubuntu` has no default port, so the bare instance URL has nothing behind it: whatever
you run gets its own port. The machine binds exactly one port of its own, so every other port is
yours:

| URL | What |
| - | - |
| `{id}-6080.agent37.app` | The XFCE desktop, with Firefox |

The dashboard opens it with a button. For a shell of your own, use
[SSH](https://www.agent37.com/docs/agents-api/ssh.md) (one `agent37 ssh setup` first), or [exec](https://www.agent37.com/docs/agents-api/exec.md) for one-off
commands:

```bash curl theme={null}
ssh root@ab12cd34ef.agent37.app
```

Anything you do serve gets a URL like every other instance: `{id}-{port}.agent37.app` for your
workspace's keys, or a [public port](https://www.agent37.com/docs/agents-api/public-ports.md) for an unauthenticated one.

## Sizing and price

The same four [shapes](https://www.agent37.com/docs/agents-api/instance-sizing.md) plus 8 vCPU / 64 GB, and compute meters at 2.5x the default rate:
a VM's RAM is reserved for it alone and its vCPUs are its own. Disk is unchanged at \$0.09 per GB
per month.

| cpu | memory | Allowed disk | Disk used for this price | Monthly price |
| - | - | - | - | - |
| 2 | 4 GB | 2-60 GB | 4 GB | \$11.36 |
| 4 | 8 GB | 2-100 GB | 6 GB | \$22.54 |
| 4 | 16 GB | 2-100 GB | 12 GB | \$37.08 |
| 4 | 32 GB | 2-100 GB | 24 GB | \$66.16 |
| 8 | 64 GB | 2-100 GB | 48 GB | \$132.32 |

The wallet needs a day of the VM's compute at create, which the \$5 starter credit covers for every size.

When you omit `resources`, `agent37-ubuntu` defaults to 2 vCPU / 4 GB RAM / 12 GB disk
(\$12.08/month), and `agent37-android` defaults to 4 vCPU / 8 GB RAM / 12 GB disk
(\$23.08/month). These VM templates default to 12 GB disk even when you choose another CPU/RAM
shape; pass `resources.disk` to choose a different size within that shape's range.

## Lifecycle

`stop`, `start`, `restart`, `update`, and `resize` all work, and your billed disk survives every
one of them. The machine cold-boots on `start` and on any `resize`, so in-memory state is lost:
anything that has to outlive a restart belongs in a file under `$HOME`.

Growing the disk extends it in place and your filesystem grows into the new space on the next
boot, so the data is kept. Disk only grows, as on every instance.

## Backups

[Backups](https://www.agent37.com/docs/agents-api/instance-backups.md) work exactly as they do on any other instance: a week of
daily restore points plus one you take on demand, listed and restored by id, and a restore
replaces the data it finds rather than merging into it.

Two things are worth knowing on a VM. A backup is taken from the machine's disks, so it captures
what your programs have written to disk, not what they are still holding in memory: a database is
backed up the way pulling the power cord would leave it, and recovers on the next start the same
way. That is the same guarantee a VPS snapshot gives you, and it is why a backup that has to be
exact should be taken with the machine stopped, or alongside your database's own dump. And a
restore cold-boots the machine, so in-memory state is lost either way.

## Auto-sleep

[Auto-sleep](https://www.agent37.com/docs/agents-api/instance-auto-sleep.md) works the way it does on a sandbox, and it is off
unless you ask for it. Once nothing has moved through the machine's URLs for
`idle_timeout_seconds`, its memory is saved to disk, its CPU and RAM are released, and it bills
the disk rate alone. The next request wakes it and is served on the way through. Wake time
depends on memory size and whether the saved state can be restored. A successful memory restore
resumes running processes; if that checkpoint is unusable or the instance moves hosts, it
cold-boots instead. Keep anything that must survive a wake on the persistent disk.

## What is not available yet

| | |
| - | - |
| Changing type | An instance is a VM or it is not, for its whole life. To move, create the one you want and copy your data across. |

Everything else on this reference behaves identically: [public ports](https://www.agent37.com/docs/agents-api/public-ports.md),
[domains](https://www.agent37.com/docs/agents-api/domains.md), [SSH keys](https://www.agent37.com/docs/agents-api/ssh.md), [logs](https://www.agent37.com/docs/agents-api/logs.md),
[metrics](https://www.agent37.com/docs/agents-api/metrics.md), [exec](https://www.agent37.com/docs/agents-api/exec.md), and
[fork](https://www.agent37.com/docs/agents-api/instances/fork.md), which copies the machine's files onto a second machine of
its own and leaves this one running. [Crons](https://www.agent37.com/docs/agents-api/crons.md) post a
prompt to an agent's chat API, so they need a template that serves one: `agent37-ubuntu` does not
and refuses them, while your own image takes them like any other instance.


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