# Run it

Native video processing requires Linux x86-64/ARM64 or Windows with the video
sandbox available. macOS and other unverified platforms currently refuse these
video paths, including JetKVM's combined video/control connection; they do not
fall back to an unsandboxed decoder. See [Native video isolation](https://github.com/qkvm/qkvm/blob/main/SECURITY.md#native-video-isolation)
for platform requirements and limitations.

**As a program** (Python 3.11 or newer):

```
pip install qkvm
qkvm
```

Then open http://127.0.0.1:8787/. Settings are kept in the
folder `.qkvm` in your home folder (on Windows `%USERPROFILE%\.qkvm`), whatever folder you
start it from; `--data-dir` puts them elsewhere. This is "the data folder" below, and qKVM
says where it is every time it starts. Its independent server storage key is kept outside
that directory, by default in `<data-directory>.keys/vault.key`. Back up that key separately.
For an existing installation, follow [vault migration](https://github.com/qkvm/qkvm/blob/main/SECURITY.md#migrating-an-existing-data-folder)
before upgrading; the protected format cannot be read by older versions.

Where the system's Python refuses `pip install` outside an environment of its own (Debian,
Ubuntu and others do), `pipx install qkvm` does the same and makes that environment for you.

**As a container:**

```
docker run -d --name qkvm --restart unless-stopped --read-only --tmpfs /tmp --cap-drop ALL --security-opt no-new-privileges:true -p 8787:8787 -v qkvm-data:/data -v qkvm-keys:/keys qkvm/qkvm --https --setup-code
```

Then open `https://<this machine>:8787/` and choose a password using the setup code
shown by `docker logs qkvm`. Verify the generated certificate on the host before trusting
it in the browser, or install a certificate trusted by your clients. These instructions
and the supplied Compose file enable HTTPS and protect remote first-account creation
with a setup code from the first request. Existing accounts are preserved.

The image is there for amd64 and arm64 (the same
one is at `ghcr.io/qkvm/qkvm`) and runs as an unprivileged user; settings live in the
`qkvm-data` volume. (If you mount a folder of your own at `/data` instead, it has to be
writable by that user, uid 10001. Where a start refuses files of another account there, the
lines it gives name the paths inside the container and the user by that number.) The
[`docker-compose.yml`](https://github.com/qkvm/qkvm/blob/main/docker-compose.yml) in the
source runs it the same way and locked down further, on a read-only file system and without
capabilities: put that file in a folder and run `docker compose up -d` there. To update,
`docker compose pull && docker compose up -d`; without compose, `docker pull qkvm/qkvm`,
then remove the container and run it again.

The `qkvm-keys` volume contains the independent server storage key and must survive every
container replacement. Back it up separately from `qkvm-data`; a copy of both can open the
stored vault. A copied data volume plus an account password or its automatic-unlock key is
insufficient without the server storage key. For a separately managed key, bind-mount its file
read-only and set `QKVM_VAULT_KEY_FILE`. The key file has to be a regular file, not a link, owned
by the account qKVM runs as (uid 10001 in the image) with permissions 0400 or 0600: Kubernetes
secret volumes (links) and Docker swarm secrets (owned by root) are refused as they are.
`QKVM_UNLOCK_FILE` controls the inner automatic
unlocking policy and is a different key. See [Security](https://qkvm.com/docs/security-policy) for migration, backup
and locked-start behavior.

To run it in a container beside Tailscale's or NetBird's, with the tailnet's machines found and a certificate browsers
trust for its tailnet name, see [Over Tailscale or NetBird](https://qkvm.com/docs/over-tailscale-or-netbird).

For a reverse proxy that terminates HTTPS, publish the backend only on loopback
(`-p 127.0.0.1:8787:8787`) or an isolated private container network. Only then omit
`--https` from the backend command; retain `--setup-code`. Do not expose the HTTP
backend to untrusted clients. See [How it is protected](https://qkvm.com/docs/how-it-is-protected) for proxy
trust and certificate configuration.

**From the source:**

```
git clone https://github.com/qkvm/qkvm
cd qkvm
pip install .          # or, for the image:  docker build -t qkvm/qkvm .
```

The first visit walks you through four steps:

1. **Password**: choose the password of the first account, `admin`.
2. **Recovery key**: shown once. Keep it: it is the way back in if a password is forgotten.
3. **Network**: where it is reachable: this computer only, Tailscale, the local network.
   (In a container this is decided by the port mapping, `-p`, instead.)
4. **KVMs**: let qKVM find the KVMs on your network, or paste their addresses, and give
   their login; each one is checked and added.
