---
title: "Colima"
description: "Add a second Docker engine to a Mac that already has Docker, in a Colima VM on QEMU with the notary's vTPM attached, run a guest notary on it, and walk a manifest back to the Secure Enclave."
source: "EQTY Notary"
---
This tutorial starts from a Mac where Docker is already installed. At the end you run
`docker run --device /dev/tpmrm0 …` and the container gets a TPM 2.0 that the EQTY notary creates
and manages, whose endorsement seed is derived in the Mac's Secure Enclave at every start and
never stored, whose attestation key is a Secure Enclave key, and whose certificates chain to this
Mac's notary. Then it runs a notary inside the VM on that TPM, and checks that a manifest from a
container chains all the way back.

The scripts are in `MACOS_DOCKER_DESKTOP/` in the swtpm-notary repository. The same steps by hand,
without the scripts, are on the [QEMU](./qemu.mdx) page.

## Why not Docker Desktop's own engine?

Docker Desktop runs containers in a Linux VM on Apple's Virtualization.framework. That VM has no
TPM device, and Docker Desktop has no way to add one. OrbStack is the same. So you keep Docker
Desktop and its `docker` command, and add a **second Docker engine** that can have a TPM: a
[Colima](https://github.com/abiosoft/colima) VM running on QEMU, with the notary's vTPM attached.
Switching between the two is a `docker context use`. Your images, Compose files and commands stay
the same.

```text
 macOS                                                  Colima VM (QEMU + HVF)
 ┌──────────────────────────────────────────────┐      ┌──────────────────────────┐
 │ Secure Enclave ◄── eqty-notary (launchd)      │      │ dockerd                  │
 │                      │ starts, seals, signs   │      │   │                      │
 │                      ▼                        │      │   ▼                      │
 │                 swtpm-notary ◄── ctrl socket ─┼──────┤ /dev/tpmrm0 ──► container│
 │                                               │ TPM  │   (--device /dev/tpmrm0) │
 │ docker CLI ── context "colima-tpm" ───────────┼──────► docker API              │
 └──────────────────────────────────────────────┘      └──────────────────────────┘
```

## Two kinds of evidence

Two kinds of evidence come out of this setup, and they check different things.

- **TPM parts:** keys and X.509 certificates in the vTPM's NV, and the quotes the TPM signs.
  Standard tools check them: `tpm2-tools`, `openssl`, Keylime and other TPM verifiers. They
  answer "is this a genuine EQTY vTPM on that Mac, and what are its PCRs?"
- **Credential parts:** EQTY manifest statements, chained by `registeredBy`. The `eqty-manifest`
  verifier checks them. They answer "who ran what, and which notary vouches for it?"

They meet in two places: the root certificate in the vTPM carries the host notary's DID, and a
guest notary's `VCompTpmV1` credential carries the TPM parts as its evidence.

```mermaid
flowchart TB
  subgraph MAC["macOS host"]
    SE["Secure Enclave<br/>SK · K_hw · IAK backing key"]
    NOTARY["eqty-notary (launchd)<br/>holds the SK; runs swtpm-notary"]
  end
  subgraph TPM["TPM parts · tpm2-tools, openssl"]
    ROOT["Issuer root cert · NV 0x01c00100<br/>self-signed by the SK · SAN = notary DID"]
    EK["EK cert · NV 0x01c0000a<br/>EK in swtpm memory, seed from the Secure Enclave"]
    IAK["IAK cert · NV 0x01c90100<br/>IAK held by the Secure Enclave"]
    AK["Guest notary AK cert<br/>issued by the IAK + TPM2_Certify"]
    Q["Quote · PCRs + nonce<br/>signed by the IAK or AK"]
  end
  subgraph CRED["Credential parts · eqty-manifest"]
    L0["VCompSecureEnclaveV1<br/>host notary identity"]
    TID["VCompTpmV1<br/>guest notary identity<br/>evidence = quote + AK cert + EK cert"]
    PROC["VCompContainerV1<br/>per-binary key of the calling binary"]
    WORK["Data / Metadata / Computation<br/>registrations of the workload"]
  end
  SE --> NOTARY
  NOTARY -->|signs| ROOT
  ROOT --> EK
  ROOT --> IAK
  IAK -->|issues + certifies| AK
  AK -->|signs| Q
  NOTARY -->|issues| L0
  ROOT -.-|same DID| L0
  AK -.->|carried as evidence| TID
  Q -.->|carried as evidence| TID
  TID -->|registers| PROC
  PROC -->|registers| WORK
```

## What you need

- A Mac with Apple silicon and an admin account.
- Docker installed: Docker Desktop, OrbStack, or just the `docker` CLI.
- [Homebrew](https://brew.sh).
- About 3 GB of free RAM for the Colima VM. On an 8 GB Mac, quit Docker Desktop and OrbStack
  while the Colima VM is running.
- The packages: the notary `.pkg`, 0.0.8 or later recommended (0.0.5 and 0.0.6 work with step 3
  and sudo), from [vcomp-notary-desktop releases](https://github.com/eqtylab-RND/vcomp-notary-desktop/releases);
  swtpm-notary's `.pkg` from [its releases](https://github.com/eqtylab-RND/swtpm-notary/releases);
  and for steps 7 to 9, the notary's Linux **arm64** `.deb` from the same notary release, which is
  installed inside the VM.

All commands run from `MACOS_DOCKER_DESKTOP/` in a checkout of swtpm-notary.

## Step 1: check the Mac

```sh
./00-check.sh
```

Checks for Apple silicon, Homebrew, the `docker` command, the notary and swtpm-notary, and free
memory. It prints what is missing and changes nothing.

## Step 2: install what is missing

```sh
./01-install.sh ~/Downloads/eqty-notary-0.0.8-macos-arm64.pkg ~/Downloads/eqty-swtpm-notary-0.10.2-eqty.1-arm64.pkg
```

Installs both packages (skip the arguments if they are already installed), and Colima and QEMU
with Homebrew.

## Step 3: turn on hardware-rooted vTPMs (notary 0.0.5 and 0.0.6 only)

```sh
./02-configure-notary.sh
```

With notary 0.0.7 or later this is a no-op: with swtpm-notary installed, new vTPMs are
hardware-rooted by default, and the vTPM's owner can start and show it without sudo. On an older
notary it adds `EQTY_VTPM_SWTPM`, `EQTY_VTPM_BACKING=identity` and `EQTY_VTPM_EPS=1` to the launchd
plist and restarts the notary. Upgrading an old notary package resets the plist, so run it again
after every upgrade until you are on 0.0.7.

## Step 4: create a vTPM for Docker

```sh
./03-create-vtpm.sh            # vTPM id "docker-tpm", owned by you
```

The notary creates and provisions the vTPM, writes its EK and IAK certificates into NV, and
starts it. The output shows `backing=identity`, `hardwareEps=true` and the emulator
`/opt/eqty/swtpm-notary/bin/swtpm` with its hash.

## Step 5: start the TPM-enabled Docker engine

```sh
./04-start-docker-tpm.sh
```

The first start takes about 5 minutes while Colima downloads its VM image. The script makes sure
the vTPM is running, writes a small QEMU wrapper that attaches the vTPM to the VM, starts Colima
with `--vm-type qemu` and that wrapper, switches Docker to the `colima-tpm` context, and checks
that the VM sees `/dev/tpm0` and `/dev/tpmrm0`.

`--vm-type qemu` is required. Colima's default on macOS, `vz`, has no TPM device, the same limit
as Docker Desktop. The wrapper adds three QEMU options to the VM's boot only, not to Colima's
version checks and probes:

```text
-chardev socket,id=chrtpm,path=/var/run/eqty-notary/vtpm/docker-tpm.sock.ctrl
-tpmdev emulator,id=tpm0,chardev=chrtpm
-device tpm-tis-device,tpmdev=tpm0,ppi=off
```

`ppi=off` is required with QEMU 11.1 and later. Without it QEMU aborts at start with
`HV_BAD_ARGUMENT`.

## Step 6: run a container with the TPM and verify it

```sh
./05-verify.sh
```

Builds a small image with `tpm2-tools` and runs it with
`docker run --rm --device /dev/tpmrm0 -e TPM2TOOLS_TCTI=device:/dev/tpmrm0 eqty-tpm2 …`. Inside
the container it checks that the IAK certificate in NV `0x01c90100` chains to the root certificate
in NV `0x01c00100`; that the root's DID is the DID in the notary's published credential at
`/var/run/eqty-notary/credential.json`; and that a `tpm2_quote` with the IAK verifies. It also
checks that a container started without `--device` has no TPM.

```text
PASS: IAK certificate chains to the notary root stored in the vTPM
PASS: that root is this Mac's notary (did:key:zDnae…)
PASS: quote signed by the Secure Enclave-held IAK verifies
PASS: a container without --device has no TPM
```

To use the TPM in your own containers, add the device to `docker run`, or in Compose:

```yaml
services:
  agent:
    image: your-image
    devices: ["/dev/tpmrm0:/dev/tpmrm0"]
    environment: { TPM2TOOLS_TCTI: "device:/dev/tpmrm0" }
```

Pass `/dev/tpmrm0`, the kernel's resource-managed device, not `/dev/tpm0`, so that several
containers can use the TPM at once.

## Step 7: run a notary inside the VM, on the vTPM

So far the container talks to the TPM directly. To get **credentials**, run the EQTY notary inside
the Colima VM too. That guest notary uses the VM's TPM, the Mac notary's vTPM, as its hardware
root:

```sh
./08-install-guest-notary.sh ~/Downloads/eqty-notary_0.0.8_arm64.deb
```

The script turns on IMA in the VM by adding `ima_policy=tcb` to its kernel command line and
restarting it, which restarts the vTPM first; turns off Key Guardian with a systemd drop-in
**before** installing, so the guest notary's chain ends at the Mac rather than at a Key Guardian
certificate it would otherwise prefer; installs the package; and waits until `/v1/isReady`
answers `READY`, about 30 seconds.

On start the guest notary reads the vTPM's EK and IAK certificates from NV, creates its own AK and
has the IAK certify it, quotes PCR 9 and 10, and issues its `VCompTpmV1` identity carrying the
quote and certificates as evidence. Containers reach it at `http://100.100.100.200:8066`, and it
issues a `VCompContainerV1` for each calling binary.

## Step 8: run simple.py in a container

```sh
./09-run-simple-py.sh
```

Builds `simple.py` from [eqtylab/container_example](https://github.com/eqtylab/container_example/tree/main/simple_py)
at a pinned commit, since the public image is amd64-only, and runs it with
`ENDPOINT=http://100.100.100.200:8066`. The EQTY SDK signs every statement through the guest
notary. The manifest is written to `out/manifest_simple.json`.

## Step 9: walk the manifest back to the hardware key

```sh
./10-verify-chain.sh
```

Copies the Mac notary's published identity manifest into `out/` and runs `check-chain.py` on the
two manifests. It checks the TPM parts: the certificate chains, guest notary AK to vTPM IAK to
root and vTPM EK to root; that the root's DID is the Mac notary that issued the host identity;
that the quote is signed by the certified AK, that its nonce is the credential's `userData`, and
that its PCR digest matches the credential's PCR values; and that the nonce is the hash of an IMA
entry carried in the manifest, so the quote commits to "the VM's kernel measured
`/usr/local/bin/eqty-notary` with this hash into PCR 10". And the credential parts: that
`simple.py`'s statements are registered by its process key, and that key's credential by the
guest notary.

```text
PASS: quote signature verifies under the AK (ECDSA P-256)
PASS: quote nonce (extraData) is the credential's userData
PASS: quote PCR digest matches the credential's PCRs [9, 10]
PASS: the quote nonce is the hash of an IMA ima-ng entry carried in the manifest
PASS: VCompTpmV1 is registered by the guest notary itself
PASS: VCompContainerV1 for did:key:zDnaekGAuuSyVKVDDkTZ... is registered by the guest notary

chain: workload statements -> process key -> guest notary -> AK -> vTPM IAK -> host notary SK (Secure Enclave)
```

To check the credentials' signatures too, set `EQTY_MANIFEST_SKILL` to the
[eqty-manifest](https://github.com/eqtylab/eqty-skills) verifier's directory and the script runs
it. Today it reports the two EQTY identity credentials as *not checked*: it does not yet recognise
their `identity-attestation/v1` context.

## Day to day

| Task                                 | Command                                                                              |
| ------------------------------------ | ------------------------------------------------------------------------------------ |
| Stop the TPM engine                  | `./06-stop.sh`; the vTPM stops with the VM                                           |
| Start it again                       | `./04-start-docker-tpm.sh`; restarts the vTPM first                                  |
| Use Docker Desktop instead           | `docker context use desktop-linux`; quit Colima first on an 8 GB Mac                 |
| Back to the TPM engine               | `docker context use colima-tpm`                                                      |
| After a Mac reboot or notary restart | `./04-start-docker-tpm.sh`                                                           |
| Remove everything                    | `./07-remove.sh`; deletes the VM and crypto-shreds the vTPM. Irreversible            |
| Start on demand                      | `docker eqty use qemu`, then `docker eqty compose up`. See [docker eqty](../docker-eqty.mdx) |

The EK and IAK survive restarts: the seed is re-derived in the Secure Enclave every time, and QEMU
resets the TPM at every VM start so each boot starts with clean PCRs. Restarts are manual: a vTPM
stops when its VM powers off or the notary restarts, and nothing restarts it automatically. All
containers in one VM share one vTPM, and so one EK and one IAK; for separate identities, use more
profiles, each with its own vTPM (`./03-create-vtpm.sh other-id`, then
`./04-start-docker-tpm.sh other-id other-profile`).

## What the TPM proves, and what it does not

| Key          | Where it lives                                                            | Vouched for by                                                                                                           |
| ------------ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| Notary SK    | Secure Enclave                                                            | The Developer ID-signed notary (`VCompSecureEnclaveV1`). Apple does not attest Secure Enclave keys for daemons, so this root is self-reported |
| vTPM EK      | swtpm memory; the seed comes from the Secure Enclave and is never stored | EK certificate signed by the notary SK, naming the vTPM and the swtpm binary's hash                                       |
| vTPM IAK     | Secure Enclave                                                            | IAK certificate signed by the notary SK, same extension                                                                   |
| A quote      | Signed by the IAK                                                         | The IAK certificate                                                                                                       |

A verifier can conclude that these PCR values were signed by a key that only this Mac's Secure
Enclave can use, via the notary's measured swtpm. IMA in the VM is kernel-extended into PCR 10
from boot; the manifest carries the IMA entry for the guest notary's own binary, not the VM's full
log, so a verifier can confirm the notary binary was measured but cannot replay PCR 10.

A verifier **cannot** conclude that Apple vouches for the Mac; that the container's own code is
trustworthy, which is what PCR and IMA measurements are for; or which of several containers
sharing the VM made the call.

## Troubleshooting

| Symptom                                                                                     | Cause and fix                                                                                                         |
| ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `colima start` fails at once; `~/.colima/_lima/colima-tpm/ha.stderr.log` mentions the TPM socket | The vTPM is not running: `./04-start-docker-tpm.sh` starts it first; or check `eqty-notaryctl vtpm list`        |
| QEMU aborts with `HV_BAD_ARGUMENT`                                                          | `ppi=off` is missing; regenerate the wrapper with `./04-start-docker-tpm.sh`                                          |
| No `/dev/tpm*` in the VM                                                                    | Colima started without the wrapper or with `vz`. `./06-stop.sh`, then `./04-start-docker-tpm.sh`                     |
| `vtpm create` fails and the notary log mentions `--eps`                                     | The notary is using stock swtpm: run `./02-configure-notary.sh` again                                                 |
| `eqty-notaryctl` has no `vtpm` command                                                      | The notary is older than 0.0.5                                                                                        |
| `docker` talks to the wrong engine                                                          | `docker context use colima-tpm`; Docker Desktop and OrbStack may make themselves the default                          |
| `check-chain.py` fails and the AK certificate's issuer is "Eqty Key Guardian Root"          | The guest notary got a Key Guardian certificate before it was turned off; rerun `08-install-guest-notary.sh`, which removes it |
| Colima warns that the QEMU binary is not signed with the hypervisor entitlement             | Harmless: that is the wrapper script, which runs Homebrew's signed QEMU                                               |
| `launchctl bootstrap` fails with `Input/output error 5`                                     | The old daemon had not finished unloading. Run the script again                                                       |

## Files

| File                                           | What it does                                                                        |
| ---------------------------------------------- | ----------------------------------------------------------------------------------- |
| `00-check.sh`                                  | Checks prerequisites; changes nothing                                               |
| `01-install.sh`                                | Installs the EQTY packages (optional arguments) and Colima and QEMU                 |
| `02-configure-notary.sh`                       | Enables hardware-rooted vTPMs in the notary's launchd plist (notary 0.0.5 and 0.0.6) |
| `03-create-vtpm.sh [id]`                       | Creates the vTPM, default `docker-tpm`, for your user                               |
| `04-start-docker-tpm.sh [id] [profile]`        | Starts the vTPM, writes the QEMU wrapper, starts Colima, switches context           |
| `05-verify.sh`                                 | Runs the container checks                                                           |
| `06-stop.sh [profile]`                         | Stops the Colima VM                                                                 |
| `07-remove.sh [id] [profile]`                  | Deletes the VM, the wrapper and the vTPM                                            |
| `08-install-guest-notary.sh <deb> [id] [profile]` | Turns on IMA in the VM, installs and configures the notary inside it             |
| `09-run-simple-py.sh [profile]`                | Runs `simple.py` in a container through the guest notary                            |
| `10-verify-chain.sh [manifest]`                | Walks the manifest back to the Mac's Secure Enclave key                             |
| `check-chain.py`                               | The chain check itself; python3 and openssl only                                    |
| `Dockerfile`, `compose.yaml`                   | The `eqty-tpm2` test image, and a Compose example with the TPM device               |
| `samples/`                                     | The host manifest and the `simple.py` manifest from a run, and what verifies        |