Running in Docker
From version 2.31.0 WireMock has an official Docker image.
Start a single WireWock container with default configuration
docker run -it --rm \ -p 8080:8080 \ --name wiremock \ wiremock/wiremock:2.35.0
Access http://localhost:8080/__admin/mappings to display the mappings (empty set)
Start with command line arguments
The Docker image supports exactly the same set of command line arguments as the standalone version. These can be passed to the container by appending them to the end of the command e.g.:
docker run -it --rm \ -p 8443:8443 \ --name wiremock \ wiremock/wiremock:2.35.0 \ --https-port 8443 --verbose
Mounting stub mapping files
Inside the container, the WireMock uses
/home/wiremock as the root from which it reads the
__files directories. This means you can mount a directory containing these from your host machine into Docker and WireMock will load the stub mappings.
To mount the current directory use
-v $PWD:/home/wiremock e.g.:
docker run -it --rm \ -p 8080:8080 \ --name wiremock \ -v $PWD:/home/wiremock \ wiremock/wiremock:2.35.0
Running with extensions
WireMock extensions are packaged as JAR files. In order to use them they need to be made available at runtime and WireMock must be configured to enable them.
For example, to use the Webhooks extension we would first download wiremock-webhooks-extension-2.35.0.jar into the
extensions directory under our working directory.
Then when starting Docker we would mount the extensions directory to
/var/wiremock/extensions and enable the webhooks extension via a CLI parameter:
docker run -it --rm \ -p 8080:8080 \ --name wiremock \ -v $PWD/extensions:/var/wiremock/extensions \ wiremock/wiremock \ --extensions org.wiremock.webhooks.Webhooks