# OpenHands

[OpenHands](https://docs.openhands.dev/openhands/usage/sandboxes/docker) runs its agent in Docker containers and is given the Docker socket to start them, so it controls whichever engine it is pointed at. Run that engine inside a microVM: a kosa8 Cloud sandbox created with `--docker` runs its own `dockerd`, and OpenHands, its containers and the socket all stay in that VM.

**How this page was checked**

The kosa8 commands against kosa8's source and the [universal image](https://docs.kosa8.com/guides/cloud-images/#full) notes on Docker inside a sandbox, November 2026. OpenHands itself was not run in this setup; its `docker run` command and image versions are from OpenHands' documentation, so check there for current ones.

## Create a sandbox that runs Docker

```
$ kosa8 cloud login
$ kosa8 cloud sandbox create --size 4x8 --image kosa8-template/universal-24.04-20261115.2 \
    --docker --name openhands --ttl 4h --on-timeout delete
$ kosa8 cloud sandbox exec -d openhands -- sh -c 'dockerd > /var/log/dockerd.log 2>&1'
$ kosa8 cloud sandbox exec openhands -- docker run --rm hello-world
```

`--docker` needs a sized create, and makes the sandbox persistent, so the daemon outlives the command that starts it. The sandbox's container gets the privileges a daemon needs (its own cgroup tree, every capability, no seccomp filter); those hold only inside its microVM, which stays the boundary. Sandboxes with Docker enabled always run on a kosa8 host. Without `--docker`, `dockerd` exits with `Devices cgroup isn't mounted`.

## Start OpenHands

```
$ kosa8 cloud sandbox exec openhands -- docker run -d --pull=always \
    -e AGENT_SERVER_IMAGE_REPOSITORY=ghcr.io/openhands/agent-server \
    -e AGENT_SERVER_IMAGE_TAG=1.26.0-python \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /workspace/.openhands:/.openhands \
    -p 127.0.0.1:3000:3000 \
    --add-host host.docker.internal:host-gateway \
    --name openhands-app \
    docker.openhands.dev/openhands/openhands:1.8
$ kosa8 cloud ssh openhands -- -L 3000:localhost:3000
```

The socket mounted here is the sandbox's own engine. The UI is bound to 127.0.0.1 inside the sandbox; with the tunnel open, browse to `http://localhost:3000` and enter your model provider and key in OpenHands' settings. [A preview URL](https://docs.kosa8.com/guides/cloud-previews/) (`kosa8 cloud preview open openhands 3000`) also works, if you want an https link instead of a tunnel.

## Settings

| Flag | Here | Notes |
|---|---|---|
| `--size` | `4x8` | Required with `--docker` |
| `--image` | `kosa8-template/universal-24.04-20261115.2` | Has `dockerd`, `containerd`, `runc`, the Docker CLI and git |
| `--ttl`, `--on-timeout` | `4h`, `delete` | A deadline for a forgotten sandbox |
| `--allow`, `--preset`, `--no-internet` | not set | Image pulls use the sandbox's network, so a tight list must include the registries; see [Egress controls](https://docs.kosa8.com/guides/cloud-egress/) |
| `--secret` | not set | Keeps a key out of the sandbox, but only for a client that can be pointed at the broker's URL |

## Clean up

```
$ kosa8 cloud sandbox rm openhands
```

## Why not the local Docker API

kosa8's local Docker-compatible API refuses, on purpose, to mount its socket into a container, because a container holding the socket controls every other container. OpenHands' documented command mounts it, so pointing OpenHands at kosa8 with `DOCKER_HOST` is not expected to work. A sandbox with its own engine gives OpenHands the socket it expects, inside a VM.

## What it does not cover

- The model key you enter in OpenHands is inside the VM. Use a dedicated key with a spending limit.

- OpenHands' own containers are not isolated from each other beyond what Docker gives inside the VM.

- The network follows your organization's policy unless you set one on the sandbox.

- kosa8 does not detect or stop prompt injection; it limits what an injected instruction can reach.

The overview with FAQs is on kosa8.com: [Run OpenHands in a microVM sandbox](https://kosa8.com/docs/integrations/openhands/).

---
Source: https://docs.kosa8.com/guides/openhands/
