Skip to main content

Serve Mode

One of the Runner’s available modes is serve mode. The runner can be started in serve mode by setting the WMC_DEFAULT_MODE environment variable to serve, or switched to this mode using the Runner’s switch endpoint. This mode starts a local playback session that will continue to serve your configured services until the runner is stopped or its mode is switched.

Serve Configuration

The serve session started by the Runner can be configured via the same mechanism as the run command of the WireMock CLI - either via a values file or via environment variables. Just like the WireMock CLI, by default the Runner will expect a WireMock environment file in the .wiremock directory in the current working directory of the container.

Starting the Runner In Serve Mode

When starting the runner in serve mode you will need to publish the appropriate ports for the services you are running along with the port you have configured for the Runner. Here is a typical example on Linux or macOS when running the Runner on port 9999 and serving two services:
docker run \
  -e WMC_DEFAULT_MODE='serve' \
  -e WMC_ADMIN_PORT='9999' \
  -e WMC_API_TOKEN='<wmc-api-token>' \
  -v ./.wiremock/:/work/.wiremock/ \
  -p 9999:9999 \
  -p 8080:8080 \
  -p 8081:8081 \
  wiremock/wiremock-runner:latest