Skip to content

Install MockHub on your own host

Before you begin

You need
  • A Linux host with Docker Engine 25.0 or later and the Compose plugin 2.24 or later
  • The release bundle and MockHub's release public key, received separately
  • Four hostnames and a wildcard you can point at the host
  • A mail relay the host can send through

A self-hosted installation is installed from a release bundle MockHub signs. You check the bundle, load it, fill in the settings, and the mockhub command starts and checks the stack and creates the first administrator.

A release arrives as a directory, mockhub-<release>-<arch>/, or as that directory in one .tar with its SHA-256 beside it. MockHub gives you its release public key through another channel than the bundle, such as your contract’s annex, or read out on a call and compared by fingerprint. Check the bundle with OpenSSL alone before you use anything in it:

Terminal window
cd mockhub-v1.4.0-amd64
base64 -d MANIFEST.sig > /tmp/manifest.sig
openssl dgst -sha256 -verify mockhub-release.pub -signature /tmp/manifest.sig MANIFEST # Verified OK
awk '$1 == "file" { print $2 " " $3 }' MANIFEST | sha256sum --check --strict --quiet # silent when intact

cosign verify-blob --key mockhub-release.pub --signature MANIFEST.sig --insecure-ignore-tlog MANIFEST checks the same signature. Once installed, ./mockhub verify BUNDLE makes both checks with the keys in keys/.

In the bundle What
MANIFEST The release, its date, architecture and the releases it upgrades from; every image and file with its checksum
MANIFEST.sig MockHub’s signature of MANIFEST
dist/ What the installation directory holds
images/ Each image, for a host that does not pull from a registry
sbom/, NOTICES.md Each image’s software bill of materials, and the third-party notices
  1. Copy the bundle’s dist/ into the installation directory, for example /opt/mockhub:

    Terminal window
    cp -a mockhub-v1.4.0-amd64/dist/. /opt/mockhub/
  2. Load the bundle, from the installation directory:

    Terminal window
    ./mockhub load /path/to/mockhub-v1.4.0-amd64

    It verifies the bundle again, checks that the directory holds its files unchanged, loads its images and records its signed manifest. For a bundle without images, install pulls each missing one from its registry later and checks it. A bundle with images needs no registry at all.

  3. Point four DNS records and a wildcard at the host: API_HOST, UI_HOST, DOCS_HOST, GATEWAY_HOST and *.GATEWAY_HOST, such as api.mockhub.example.com, mockhub.example.com, docs.mockhub.example.com, mock.example.com and *.mock.example.com. Every project answers on its own subdomain of the gateway host. Open the firewall for the features you will use; see Network requirements.

  4. Run ./mockhub install. It first checks the directory against the signed manifest, as every run does. The first run writes .env from env.template, with fresh secrets, and stops, listing the settings to fill in. If a secret cannot be made, the error names the setting; run ./mockhub install again once the cause is fixed, and it keeps the secrets already made.

  5. Fill them in .env: the four hostnames, the support, abuse and security mailboxes, the mail relay, and TLS_MODE. See Configuration reference and Choose a TLS mode. Review the optional settings too, above all REGISTRATION_MODE, AI_GENERATION_POLICY and PASSWORD_BREACH_CHECK.

  6. Run ./mockhub install again at a terminal, naming the first administrator:

    Terminal window
    ./mockhub install --admin-email admin@example.com

    It asks for the administrator’s password twice, and creates the administrator before anyone can reach the installation. To pass the password from a script, add --admin-password-stdin and send it on standard input; the first line is used. See Create the first administrator.

  7. Install the licence MockHub sent you.

  8. Create a canary: a project with one mock whose body never changes. Set CANARY_URL to its full https:// address and CANARY_BODY to its exact body in .env, so ./mockhub status checks a real mock end to end.

install ends with the address of the app, Installed v1.4.0: https://mockhub.example.com. On the way, it checked the host, that the files and images are the signed release’s and the edge’s configuration, then started the stack with ingress closed behind a maintenance page: the datastores, the database migrations, the installation’s plan, the WireMock registration, the first administrator, the services, a check from inside the edge, ingress opened, a check through the public listener, and the scheduler last.

Sign in at the UI_HOST address as the administrator. ./mockhub status checks the whole installation at any time. If the browser shows MockHub could not start instead, see The browser says MockHub could not start.

  • Back it up. Add a recovery key holder and take a first backup; see Back up and restore an installation.
  • Keep .env safe. It holds the secrets that decrypt stored credentials and authenticator secrets, and nothing recovers them if it is lost. Every backup carries an encrypted copy. Never commit it or send it to anyone.

Edit .env and run ./mockhub install again. It changes no secret: it applies the settings, closing ingress behind the maintenance page while it restarts what changed, and checks the stack before it reopens. The same command reopens a stack a failed maintenance window left closed, once the cause is fixed.

  • install refuses a directory with no recorded signed manifest. --unverified installs one anyway, with a warning that status repeats, for a build MockHub tests before bundling it.
  • Ingress stays closed until the installation has an administrator. Without --admin-email, install asks for the address at a terminal, and otherwise stops with the command to run.
  • An image comes only from where the manifest says. An image the bundle carries comes only from ./mockhub load; when it is missing, install names its archive and refuses. An image from a registry is pulled only when it is missing, and never with --no-pull. An image on the host under the release’s name but with another ID is refused, not replaced: remove that tag with docker image rm and run the command again.
  • The host needs a kernel MongoDB can run on: not upstream 6.19 to 7.0.13. install, status, restore and upgrade check it, and the Docker versions, because the host may be patched between maintenance windows.
  • A newer major Docker Engine or Compose line than a release was tested with is warned about, not refused.
  • install and backup refuse while a restore or an upgrade is unfinished; finish or roll it back first.

Report a problem with this page