# Run Capy Dock on Briq

URL: https://briq.cloud/docs/guides/run-capy-dock

> Pair a dedicated Briq sandbox with your Capy account and run threads on its saved home.

Recipe:

- [Capy Dock](https://briq.cloud/cookbook/capy-dock.md): A dedicated Capy device with interactive pairing and a saved home for threads.

Start a dedicated sandbox, then pair it yourself in an interactive terminal.
Capy threads run as `capy`, a non-root user without sudo access.

```bash
briq run capy-dock --stack capy
briq shell <briq-id>
```

Use the Briq ID returned by `run`. The native shell needs a terminal on your computer.
Do not use `briq exec`, an agent tool, terminal recording, or redirected output for pairing.

1. Briq starts a supervisor with a 5 GB volume mounted at `/home/capy`.
2. No port is exposed. The device stays offline until you install, pair and enable Dock.
3. The whole home persists: Dock's identity, installation, repository clones and thread worktrees.

## Install and pair

In the Briq shell, switch to the dedicated account:

```bash
su - capy
id -u
```

The UID must be `1001`, not `0`. Keep shell tracing off.
Run the [official installer](https://docs.capy.ai/dock) as this user:

```bash
curl -fsSL https://downloads.capy.ai/stable/dock/install.sh | sh
export PATH="$HOME/.capy/bin:$PATH"
flock -n -F "$HOME/.capy-dock.lock" capy dock
```

The installer checks the binary's checksum. Linux requires glibc on x64 or arm64; Alpine is unsupported.
It installs under `~/.capy/bin` and `~/.capy/dock-install`.

1. Open the link or scan the QR shown in this terminal using your own Capy account.
   Alternatively, open **Settings → Devices → Pair a device** and enter the displayed code.
2. Check the hostname and system. Choose your organization and name the device.
3. Confirm **This code is on a machine I am setting up right now**, then **Approve**.
4. Back in the terminal, confirm that the organization and device name are yours.
5. Press **Ctrl-C** and wait for your shell prompt before continuing.

Approve only a code on a machine you are setting up. Do not share the link, QR or code.
The interactive shell audits session metadata, not terminal contents. Keep its output out of logs and screenshots.

## Link repositories and enable the service

Still as `capy`, clone repositories inside the saved home. For example:

```bash
mkdir -p ~/src
git clone https://github.com/your-org/your-repo.git ~/src/your-repo
capy dock dirs add ~/src/your-repo
capy dock verify
capy dock doctor
touch ~/.capy-dock-enabled
exit
exit
```

Replace the example repository. Set up private repository access interactively; do not put tokens in clone URLs or recipe fields.
Install the GitHub CLI in this account if `doctor` reports it missing and your work needs GitHub operations.
Link repository folders only, not the home or `.capy` directory.
You can also pass repeated `--dir` options when running Dock interactively.

The supervisor acquires the same exclusive lock, then starts `capy dock` without a terminal.
Its input and output go to `/dev/null`, so pairing material cannot enter service stdout or stderr.
The marker records your intent to run, not proof of pairing.

In Capy, select the device under **Machine** when creating a thread or Captain.
Choose a linked repository. Threads use git worktrees under `/home/capy/.capy/worktrees`.
Use **Settings → Devices → Access** to restrict who can run threads there.

## Restart, sleep and maintenance

```bash
briq stop <briq-id>
briq start <briq-id>
```

Ordinary stop can suspend memory; start then resumes the existing processes.
A cold stop boots the supervisor again from the same saved home. A requested supervisor shutdown retains enablement.
If Dock exits on its own or cannot start, the supervisor removes enablement instead of retrying authentication.
Check the device in Capy after restarting; recipe readiness does not prove Dock is online.

Capy's outbound connection and thread activity do not count as Briq API or router activity.
An idle Briq can sleep while Capy is working. Capy cannot wake it through a public endpoint here.
Start it through Briq when needed. An eligible plan can request `--sleep never` when creating the Briq.
Credit limits and explicit stops still apply. Briq compute is billed while running; Capy model usage remains separate.

When Dock stops, its device goes offline. Capy waits for reconnection or can move work to the cloud under device settings.
Stopping this Briq does not stop work already moved elsewhere.

Before upgrading, changing linked directories, or pairing again, first ensure the Briq is running:

```bash
briq start <briq-id>
briq status <briq-id>
```

Wait for **running** before continuing. This can briefly resume the old Dock from a memory snapshot.
An explicitly stopped Briq cannot run the marker-removal exec or accept a cold stop.
Then disable launch and cold-stop it:

```bash
briq exec <briq-id> -- rm -f /home/capy/.capy-dock-enabled
briq stop <briq-id> --cold
briq status <briq-id>
```

Wait until status is **stopped**, not **stopping**, before continuing.
Cold stop discards running processes and any memory snapshot; ordinary stop can resume the old Dock process.
Then start and check completion:

```bash
briq start <briq-id>
briq status <briq-id>
briq shell <briq-id>
```

Wait for **running** before opening the shell. If either operation reports an error, stop and resolve it first.
Then `su - capy`. Hold the same lock during maintenance:

```bash
flock -n -F "$HOME/.capy-dock.lock" bash --noprofile --norc
export PATH="$HOME/.capy/bin:$PATH"
```

Run the installer again to update, or use `capy dock dirs add <path>` and `remove <path>` while Dock is stopped.
Run `capy dock` directly inside this locked shell if pairing is needed. Confirm the identity, then press **Ctrl-C**.
After maintenance, `touch ~/.capy-dock-enabled`, then `exit` to release the lock.
Exit both remaining shells. If the lock is unavailable, stop and investigate; do not delete the lock file.

## Revoke and tear down

In Capy, open **Settings → Devices**, select this device, then **Revoke device**.
Follow maintenance through the confirmed cold stop: start if needed, remove `/home/capy/.capy-dock-enabled`, then cold-stop and confirm **stopped**.
Starting a stopped Briq can briefly resume the old Dock. Do not start it after that cold stop or approve a replacement code.
Revocation removes Capy's device access; it does not delete repositories, worktrees or other saved sign-ins.

```bash
briq destroy <briq-id>
```

Destroy only after pushing or copying needed work off the Briq. A local commit on this volume is deleted too.
The uncopied volume has no fork or backup to recover.
Keep the identity out of repository commits, exported files and custom images.

## When it does not start

* **Interactive terminals unavailable**: this provider cannot supply the required native TTY. Do not replace pairing with captured exec output.
* **Device stays offline**: use maintenance mode, then `capy dock status`, `doctor`, `verify` and `version` privately in the terminal.
* **Dock exited**: diagnose interactively, stop it, then create the enable marker again. Service output is intentionally discarded.
* **Lock unavailable**: another Dock or maintenance session owns it. Close that session or use the completed cold-stop maintenance sequence; keep the lock file.
* **Briq slept**: start it through Briq. Select a permitted sleep policy for the work you need.

## Good to know

* Anyone with Briq team access can read the saved identity through root exec. Use a trusted team.
* Capy threads can read and change anything the `capy` user can, including its identity and worktrees.
* Each device shares this Briq's compute and disk across its threads. This does not create a separate Briq per thread.
* Keep checkpoints scoped to repository workspaces. Review Capy's device settings for checkpoints and automatic cloud moves.
* A custom image must preserve the default image's tools, UID and home contract.
