Runnable demo (Docker Compose)¶
This demo runs a small set of services and Pacto on your machine with Docker. Use it to see Pacto work against real parts:
- a container registry holds published contracts;
- an Evidence Server holds a signed report from a pretend remote environment;
- the dashboard shows all of it as one graph of who calls whom;
pacto agentwatches the containers' network connections and reports a service that says it is up but serves nothing.
It shows contracts and checks on running services. For the autonomy ladder, see the browser demo. For delivery on a real cluster, see the Kubernetes demo.
The demo is published as an OCI artifact that Docker Compose runs directly from the registry.
Run it¶
You need only Docker Compose 2.34 or
newer. That release added docker compose publish and -f oci://…. Older
versions cannot run this artifact, and the application says so itself in
x-pacto-demo.minimum-compose-version. The demo's registry is public, so no
login is needed; against a private registry, docker login <registry> first.
Resolve the release you want to the digest it published, then run that digest:
DEMO=$(docker manifest inspect -v ghcr.io/trianalab/pacto/demo:4.6.1 \
| sed -n 's/.*"digest": "\(sha256:[a-f0-9]*\)".*/\1/p' | head -1)
docker compose -f "oci://ghcr.io/trianalab/pacto/demo@$DEMO" \
-p pacto-demo up -d --wait -y
Each release publishes the demo under one tag, and you run the digest that tag
resolved to. -p pacto-demo names the project, which is
how you operate the stack afterwards: docker compose -p pacto-demo ps, logs,
stop, start and down -v all address it by name.
-y answers the one question Compose asks before it runs a stack fetched from a
registry: it lists the variables the artifact declares (the three ports below)
and waits for a yes.
Then open http://localhost:8080/#/fleet.
What you get¶
The demo has four services. checkout has two published revisions, and 1.1.0
drops an API path 1.0.0 exposed. orders declares checkout and is seen calling it, declares
payments and is never seen calling it. payments reaches the fleet as signed
evidence from a remote environment; checkout is seen calling it with no
contract declaring so.
The three edges show one of each on purpose: matched, declared but never
observed and observed but never declared. The observed calls come from a
recorded trace file. Follow the graph from orders to
checkout, open a revision to read its contract and compare checkout 1.0.0
with 1.1.0 to see a change analysed.
The Metrics page totals the run records the demo's seed published to its own registry, as unsigned statistics. They are CI records only (diffs, impact checks and publishes), because the Compose demo runs no delivery. Measure what Pacto does explains recording.
The cold start, step by step¶
Every Pacto rollout starts the same way. Every service in this demo already has a contract, so it shows the moves on a contracted fleet:
- Watch what runs. Pacto reads the contracts it has and what it sees running, and changes nothing.
- Find what no contract declares.
checkoutcallspayments, butcheckout's contract does not say so. The graph marks that call as observed but not declared. - Pactify a service.
pacto initwrites a first contract from what a service already has. The demo shows it on a plain copy ofcheckout, since every running service has a contract (see Try the CLI in the demo).
The second half is delivery, where Pacto ships changes and a person confirms what it may do on its own. Delivery runs on Kubernetes only; the Kubernetes demo shows it.
For the same moves at the command line, follow the guided tour. Its seven stories go from listing a fleet to checking what a provider promises.
Try the CLI in the demo¶
The dashboard container has the Pacto CLI, so these commands run inside it.
Ask which version checkout 1.1.0 should have been. It drops a path 1.0.0
served, so Pacto answers Required bump: major (and exits non-zero, as a CI
step would):
docker compose -p pacto-demo exec dashboard pacto diff \
oci://registry:5000/demo/checkout:1.0.0 oci://registry:5000/demo/checkout:1.1.0
Pactify a plain checkout that has only a Dockerfile. --plan shows the
contract pacto init would write and changes nothing:
docker compose -p pacto-demo exec dashboard sh -c \
'mkdir -p /tmp/checkout && printf "FROM nginx:1.27\nEXPOSE 8080\n" >/tmp/checkout/Dockerfile &&
pacto init --plan --owner commerce /tmp/checkout'
Total the run records behind the Metrics page:
docker compose -p pacto-demo exec -e PACTO_STATS_REGISTRY=registry:5000/demo/pacto-stats \
dashboard pacto stats
See what CI sees¶
The targets service publishes a signed target snapshot of the demo cluster
to registry:5000/demo/pacto-targets every 5 minutes, as the operator
does on Kubernetes. pacto impact finds it from the provider ref and needs no
kubeconfig:
docker compose -p pacto-demo exec dashboard pacto impact \
oci://registry:5000/demo/checkout:1.0.0 oci://registry:5000/demo/checkout:1.1.0
With no trust file the Targets line says unverified, so the answer stays
partial and the BREAKING change exits 2. To verify the snapshot, copy the
public key the service wrote and trust it for the demo cluster only. A bare
PEM trusts every cluster, so Pacto reads it as unscoped and partial:
docker compose -p pacto-demo cp targets:/home/pacto/targets/compose-targets.key.pub.pem .
{ echo 'keys:'; echo ' - name: compose-targets'
echo ' streams: ["compose-demo-0000-0000-0000-000000000001/*/*"]'
echo ' publicKey: |'; sed 's/^/ /' compose-targets.key.pub.pem; } >trust.yaml
docker compose -p pacto-demo cp trust.yaml dashboard:/tmp/trust.yaml
docker compose -p pacto-demo exec dashboard pacto impact --delivery-trust /tmp/trust.yaml \
oci://registry:5000/demo/checkout:1.0.0 oci://registry:5000/demo/checkout:1.1.0
Registry: registry:5000/demo (found registry:5000/demo/pacto-targets, 1 cluster read)
Targets: registry:5000/demo/pacto-targets@sha256:1be6... (cluster compose-, asOf 0m, complete, signed by compose-targets (publisher key:a59f...))
Affected consumers (1):
orders direct ... compat=compatible owner=commerce
...
Release gate: unverified
orders runs and its range ^1.0.0 accepts 1.1.0, so the gate stays
unverified (exit 2) until someone checks that orders does not call the
removed path. CI shows the same check in a pipeline.
See an inferred contract¶
The inferred service publishes the inferred contract
of every external system the demo knows to
registry:5000/demo/pacto-inferred/<identity> every 5 minutes, as the
operator does once registry is set. A Compose-only contract, card-payments,
pins stripe's inferred contract with ^0.0.1, and that range stays
unknown:
docker compose -p pacto-demo exec inferred pacto fleet get external:stripe \
--local /demo/inferred/card-payments \
--oci oci://registry:5000/demo/pacto-inferred/stripe --output-format json \
| jq '.external.provider.rangeStatus,.external.provider.rangeReason'
Connect an agent¶
pacto mcp serves the demo's fleet to an agent over
stdio. Run it in the dashboard container, so it reads the registry and the
Evidence Server at the addresses the dashboard reads them:
docker compose -p pacto-demo exec -T dashboard pacto mcp --fleet --local "" \
--oci oci://registry:5000/demo/checkout --oci oci://registry:5000/demo/orders \
--oci oci://registry:5000/demo/inventory --evidence-url http://evidence:8686 \
--stats-read-registry registry:5000/demo/pacto-stats
Give that command to your agent as a stdio MCP server. --local "" keeps the
container's working directory out of the fleet, and --stats-read-registry
gives pacto_stats the run records the Metrics page totals. The agent's first call can be
pacto_capabilities: it lists the modes, tools and caller this server serves.
The live runtime check¶
inventory is the live part. Its container is running and labelled with its
contract and the port its API is bound to (dev.pacto.contract,
dev.pacto.bind.api=8080), but nothing in it listens there. The agent service
runs pacto agent with --sink evidence --docker: it
reads those labels, watches every container's TCP sockets with eBPF, and sends
what it sees, signed with its own key, to the Evidence Server. About half a
minute after start, inventory shows INTERFACE_ABSENT on api, seen by
pacto-agent+ebpf (the kernel). Docker reports only that the container is
up, so the kernel view is what finds this.
The agent needs more access than the rest of the demo: a privileged container in
the host's PID and cgroup namespaces, running as root, with the Docker socket
and /sys/fs/cgroup mounted. Those two paths are the only host paths the demo
mounts. On Linux that means kernel 5.8 or later with BTF and cgroup v2. On
Docker Desktop (macOS and Windows) the "host" is Docker's own Linux VM. On macOS
its current kernel ships BTF and cgroup v2. Where the kernel cannot load the
program, the agent says so in docker compose -p pacto-demo logs agent and
inventory stays without that finding; everything else works unchanged.
Ports¶
8080 (dashboard), 8686 (Evidence Server) and 5051 (the demo's registry).
Override with PACTO_DEMO_DASHBOARD_PORT, PACTO_DEMO_EVIDENCE_PORT and
PACTO_DEMO_REGISTRY_PORT:
PACTO_DEMO_DASHBOARD_PORT=8081 PACTO_DEMO_EVIDENCE_PORT=8687 \
PACTO_DEMO_REGISTRY_PORT=5052 \
docker compose -f "oci://ghcr.io/trianalab/pacto/demo@$DEMO" \
-p pacto-demo-next up -d --wait -y
Two project names, two sets of ports: both run at once, and down -v on one
leaves the other untouched.
Offline¶
The service images are pulled once and cached by Docker, so --pull never runs
the demo without reaching for them again:
docker compose -f "oci://ghcr.io/trianalab/pacto/demo@$DEMO" \
-p pacto-demo up -d --wait -y --pull never
Creating the project reads the artifact from the registry, once. After that
stop, start, restart, logs and down -v work by project name with no
network beyond the stack's own.
Evidence is published as an OCI 1.1 referrer of the exact contract revision it
reports on, so the registry is the store and the Evidence Server keeps nothing.
The demo's registry is zot because the demo needs the native Referrers
API. docker compose -p pacto-demo down -v
removes the registry volume and the evidence with it.
The other demos¶
- Live dashboard demo: the same UI in your browser, without Docker. The engine and a curated fleet are compiled to WebAssembly.
- Dashboard container: the dashboard against your own services.
- Kubernetes demo: delivery: promotions, approvals, rollbacks and signed records. This demo has no cluster and no sign-in, so its dashboard's sidebar shows no Delivery item.
Next: the Quickstart takes an empty directory to a validated contract and a caught breaking change in about five minutes.