Overview
The WireMock Runner offers a way to deploy and run long-lived WireMock tasks and control the lifecycle of those tasks via an HTTP interface.Installation
The Runner is published to Docker Hub aswiremock/wiremock-runner.
Running the image will start the runner and expose the HTTP interface based on the configuration specified via
environment variables.
The following environment variables can be used to configure the runner:
WMC_DEFAULT_MODE: The mode that the runner starts in. Currently, supportsrecord-many,serve. Defaults toserveif omitted.WMC_ADMIN_PORT: The port that the admin interface is exposed on. Defaults to an available random port.WMC_API_TOKEN: The API token to use for accessing WireMock Cloud.
record-many mode:
The Runner will validate that the container is configured to run any of the available modes at startup, regardless
of the configured default mode.
Switching mode
The Runner will always start in the default mode, configurable viaWMC_DEFAULT_MODE.
Once running, the Runner’s current mode can be changed via an HTTP PUT request to /v1/mode on the Runner’s admin
port, configurable via WMC_ADMIN_PORT.
The request must contain a JSON body of the form
<DESIRED_MODE> replaced with one of the Runner’s available modes.
Example:
request
Record Many Mode
One of the Runner’s available modes isrecord-many mode.
This mode starts a multi-domain recording session that will record requests to your
configured services and flush the results to WireMock Cloud.
More information on this mode can be found in the WireMock Runner Record Many documentation.
Serve Mode
One of the Runner’s available modes isserve mode.
This mode starts a local playback session that serves your configured services from the Runner’s
container.
More information on this mode can be found in the WireMock Runner Serve documentation.
WireMock Runner vs WireMock CLI
The WireMock CLI and the WireMock Runner offer very similar functionality to each other (with the caveat that the Runner currently exposes a limited subset of the capabilities of the CLI). In fact, both tools are packaged within the same binary published to the NPM registry and Docker Hub. By default, the binary will run the CLI tool, but this can be overridden to execute the Runner by setting the environment variableWMC_RUNNER_ENABLED to true.
Example: