Quick answer: Commit a Mockoon data file and start it before your tests with mockoon-cli start --data ./mocks/store.json --port 3000, or run the same command through the official mockoon/cli Docker image or mockoon/cli-action GitHub Action. The process runs in the foreground and keeps request state in memory, so each CI job gets an isolated mock that disappears with the container. Use npm on Node runners, Docker to fix the runtime, and the action on GitHub.

Pick the runner

All three distributions wrap the same start command, so the choice is what you install and what manages the process.

Runner Start shape Best fit Handle
npm CLI npm i -g @mockoon/cli then mockoon-cli start Existing Node images Add & when the shell step must continue
Docker docker run -p 3000:3000 mockoon/cli:latest with flags after the image Fixed runtime, parallel jobs Mount the file read-only or pass a URL; file logs are off
GitHub Action uses: mockoon/cli-action@v3 with data-file and port GitHub workflows Pin the action and CLI version

One process can serve several environments by pairing multiple --data values with matching --port values. On a hand-built runner the foreground process blocks a shell step, so append & and redirect output when the same step runs tests.

Choose the data file

The --data flag accepts a native Mockoon environment file or an OpenAPI 2/3 file in JSON or YAML, from a path or URL. They are not equivalent. The native file keeps response rules, templating, and proxy behavior, while OpenAPI conversion has no equivalent for some Mockoon-only concepts, so desktop rules do not survive an export and re-import. An older CLI also cannot open a newer data file, so pin the CLI or image to the desktop major version the team saves with. Commit the file rather than fetching a mutable URL; a remote file that changes between runs makes failures hard to reproduce.

Wait for a real route

Starting is not readiness. Poll an endpoint defined in the mock, because there is no universal health path. The same loop works for npm and Docker once the port is published.

steps:
  - uses: actions/checkout@v4
  - name: Start Mockoon
    uses: mockoon/cli-action@v3
    with:
      data-file: "./mocks/store.json"
      port: 3000
  - name: Wait for a configured route
    run: |
      for i in $(seq 1 30); do
        curl -fsS http://localhost:3000/products >/dev/null && exit 0
        sleep 1
      done
      exit 1
  - run: npm test

For a shell runner, start it with mockoon-cli start -d ./mocks/store.json -p 3000 > mockoon.log 2>&1 &. Give parallel jobs separate ports or containers, since request history and generated records are shared inside one process.

Logs, admin API, and state

The CLI writes JSON transaction lines to stdout; --log-transaction adds full request and response content, which can include headers and bodies, so protect public CI logs. File logs live at ~/.mockoon-cli/logs/{mock_name}.log, but Docker disables them and --disable-log-to-file turns them off elsewhere. The admin API is on by default at /mockoon-admin; pass --disable-admin-api if the port is reachable outside the job network. Request history and runtime changes exist only in memory, so a restart returns to the committed file. That fits short-lived CI, but it also means the mock is not a shared staging backend.

Powerduck approaches the same boundary from the verification side. Its scenario runner sends an ordered request sequence, passes response values into later calls, and asserts status, headers, and fields at each step, then exports a self-contained HTML report for the whole flow. The trade-off between desktop mocking, CI hosting, and contract fidelity is in our comparison hub.

Frequently asked questions

Can the CLI run an OpenAPI file directly? Yes, pass an OpenAPI 2 or 3 JSON or YAML file to --data. Mockoon-only behavior such as response rules is not converted, so use the native environment file when those rules matter.

Does the Docker image include my mock? Not by default. Mount the file read-only and put start flags after the image name, or pass a URL. The mockoon-cli dockerize command copies data files into a self-contained image.

Is /mockoon-admin a health endpoint? No. It exposes logs and runtime controls. Check readiness against a business route you defined, and isolate the admin port from anything outside the job.

The bottom line

A committed native data file plus the action or a pinned container gives every run an isolated dependency with no leftover state. The limit is contract depth: the mock returns the branches you scripted, but it cannot prove the real service shares that schema or those rules. Keep contract tests against the actual backend, and treat CI transaction logs as debugging evidence rather than proof of production behavior.