WireMock Cloud
Secure, publicly hosted mock APIs with nothing to install. Try WireMock Cloud >
WireMock Cloud
Secure, publicly hosted mock APIs with nothing to install. Try WireMock Cloud >
From version 2.31.0 WireMock has an official Docker image.
docker run -it --rm \-p 8080:8080 \--name wiremock \wiremock/wiremock:3.13.1Access http://localhost:8080/__admin/mappings to display the mappings (empty set)
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:3.13.1 \--https-port 8443 --verboseStarting from 3.2.0-2, the Docker image supports passing command line arguments standalone version as the environment variable.
Environment variable WIREMOCK_OPTIONS can be passed to container consisting of all command line arguments e.g.:
docker run -it --rm \-e WIREMOCK_OPTIONS='--https-port 8443 --verbose' \-p 8443:8443 \--name wiremock \wiremock/wiremock:3.13.1Inside the container, the WireMock uses /home/wiremock as the root from which it reads the mappings and __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:3.13.1WireMock 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-3.13.1.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.WebhooksInside the container, the WireMock uses /home/wiremock as the root from which it reads the mappings and __files directories.
This means you can copy your configuration from your host machine into Docker and WireMock will load the stub mappings.
Wiremock utilizes a custom entrypoint script that passes all provided arguments as WireMock startup parameters. To modify the WireMock launch parameters it is recommended to override the entrypoint in your custom Docker image.
# Sample DockerfileFROM wiremock/wiremock:latestCOPY wiremock /home/wiremockENTRYPOINT ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]Configuration in compose file is similar to Dockerfile definition
# Sample compose fileversion: "3"services: wiremock: image: "wiremock/wiremock:latest" container_name: my_wiremock entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]You can also mount your local __files and mappings files into the container e.g:
# Sample compose fileversion: "3"services: wiremock: image: "wiremock/wiremock:latest" container_name: my_wiremock volumes: - ./extensions:/var/wiremock/extensions - ./__files:/home/wiremock/__files - ./mappings:/home/wiremock/mappings entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]