Giter Club home page Giter Club logo

wiremock-docker's Introduction

WireMock Docker images

Main Nightly Docker Pulls a

The official Docker image for WireMock Standalone deployments. It includes WireMock for Java under the hood, and fully compatible with its features. You can learn more about WireMock standalone on the WireMock docs site.

Quick Start

In a temporary directory, checkout the demo repository, pull the Docker image, and start the WireMock instance.

docker pull wiremock/wiremock:latest
git clone https://github.com/wiremock/wiremock-docker.git
docker run -it --rm \
  -p 8080:8080 \
  -v $PWD/wiremock-docker/samples/hello/stubs:/home/wiremock \
  wiremock/wiremock:latest

You will get a CLI output like this one:

██     ██ ██ ██████  ███████ ███    ███  ██████   ██████ ██   ██
██     ██ ██ ██   ██ ██      ████  ████ ██    ██ ██      ██  ██
██  █  ██ ██ ██████  █████   ██ ████ ██ ██    ██ ██      █████
██ ███ ██ ██ ██   ██ ██      ██  ██  ██ ██    ██ ██      ██  ██
 ███ ███  ██ ██   ██ ███████ ██      ██  ██████   ██████ ██   ██

----------------------------------------------------------------
|               Cloud: https://wiremock.io/cloud               |
|               Slack: https://slack.wiremock.org              |
----------------------------------------------------------------

port:                         8080
enable-browser-proxying:      false
no-request-journal:           false
verbose:                      false
extensions:                   response-template,webhook

Supported architectures

  • x64
  • armv7
  • armv8

Supported tags

There are multiple image tags provided for end users. These tags are available on DockerHub and GitHub Packages, see the full list here. The most important tags are listed below.

Latest images

Latest WireMock 2.x images

Deprecated and experimental tags

Using WireMock in Docker

To start WireMock with the default settings:

docker run -it --rm -p 8080:8080 wiremock/wiremock

By default, the image exposes the 8080 port for HTTP. To verify the WireMock state, access http://localhost:8080/__admin/health to display the health status and the information. The /__admin/health endpoint is available for WireMock 3.1.0 or above.

A HEALTHCHECK is also built into the docker image to allow direct querying of the docker container's health status. Under the hood, this uses the same method as above to verify the status of the container.

Configuring WireMock

You can configure WireMock using the following ways:

  • Passing the CLI arguments
  • Passing Environment variables
  • Passing configuration files via volumes
  • Building a custom image using wiremock/wiremock as a base image

Passing the CLI arguments

To start with these WireMock arguments, you can add them to the end of the command line. For example, to enable HTTPs: --https-port 8443 --verbose

docker run -it --rm -p 8443.9443 wiremock/wiremock --https-port 8443 --verbose

Using environment variables

The following environment variables are supported by the image:

  • uid : the container executor uid, useful to avoid file creation owned by root
  • JAVA_OPTS : for passing any custom options to Java e.g. -Xmx128m
  • WIREMOCK_OPTIONS: CLI options to be passed to WireMock (starting from 3.2.0-2).

Example for passing the CLI options:

docker run -it --rm \
  -e WIREMOCK_OPTIONS='--https-port 8443 --verbose' \
  -p 8443.9443 \
  --name wiremock \
  wiremock/wiremock:latest

Passing configuration files as volumes

Inside 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:{{ site.wiremock_version }}

Building your own image

Inside 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 Dockerfile
FROM wiremock/wiremock:latest
COPY wiremock /home/wiremock
ENTRYPOINT ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]

Using WireMock extensions

You can use any WireMock extension with the Docker image. They can be added via CLI and volumes, but for most of the use-cases it is recommended to build a custom image by extending the official one.

Using extensions in CLI

For old style extensions (that don't have Java service loader metadata) you need to add the extension JAR file into the extensions directory and specify the name of the extension's main class via the --extensions parameter:

# prepare extension folder
mkdir wiremock-docker/samples/random/extensions
# download extension
wget https://repo1.maven.org/maven2/com/opentable/wiremock-body-transformer/1.1.3/wiremock-body-transformer-1.1.3.jar \
  -O wiremock-docker/samples/random/extensions/wiremock-body-transformer-1.1.3.jar
# run a container using extension 
docker run -it --rm \
  -p 8080:8080 \
  -v $PWD/wiremock-docker/samples/random/stubs:/home/wiremock \
  -v $PWD/wiremock-docker/samples/random/extensions:/var/wiremock/extensions \
  wiremock/wiremock \
    --extensions com.opentable.extension.BodyTransformer

For new style extensions the --extensions part should not be included as the extension will be discovered and loaded automatically:

# prepare extension folder
mkdir wiremock-docker/samples/random/extensions
# download extension
wget https://repo1.maven.org/maven2/org/wiremock/wiremock-grpc-extension-standalone/0.5.0/wiremock-grpc-extension-standalone-0.5.0.jar \
  -O wiremock-docker/samples/random/extensions/wiremock-grpc-extension-standalone-0.5.0.jar
# run a container using extension 
docker run -it --rm \
  -p 8080:8080 \
  -v $PWD/wiremock-docker/samples/random/stubs:/home/wiremock \
  -v $PWD/wiremock-docker/samples/random/extensions:/var/wiremock/extensions \
  wiremock/wiremock

Using extensions in the Dockerfile

git clone https://github.com/wiremock/wiremock-docker.git
docker build -t wiremock-random wiremock-docker/samples/random
docker run -it --rm -p 8080:8080 wiremock-random

Access http://localhost:8080/random to show random number

Advanced use-cases

Using HTTPs

For HTTPs, the 8443 port is exposed by default. To run with HTTPs, run the following command:

docker run -it --rm -p 8443.9443 wiremock/wiremock --https-port 8443 --verbose

To check the HTTPs on the default exposed port, use https://localhost:8443/__admin to check HTTPs working.

Using the Record Mode

In Record mode, when binding host folders (e.g. $PWD/test) with the container volume (/home/wiremock), the created files will be owned by root, which is, in most cases, undesired. To avoid this, you can use the uid docker environment variable to also bind host uid with the container executor uid.

docker run -d --name wiremock-container \
  -p 8080:8080 \
  -v $PWD/test:/home/wiremock \
  -e uid=$(id -u) \
  wiremock/wiremock \
    --proxy-all="http://registry.hub.docker.com" \
    --record-mappings --verbose
curl http://localhost:8080
docker rm -f wiremock-container

Check the created file owner with ls -alR test

However, the example above is a facility. The good practice is to create yourself the binded folder with correct permissions and to use the -u docker argument.

mkdir test
docker run -d --name wiremock-container \
  -p 8080:8080 \
  -v $PWD/test:/home/wiremock \
  -u $(id -u):$(id -g) \
  wiremock/wiremock \
    --proxy-all="http://registry.hub.docker.com" \
    --record-mappings --verbose
curl http://localhost:8080
docker rm -f wiremock-container

Check the created file owner with ls -alR test

Docker Compose

Configuration in compose file is similar to Dockerfile definition

# Sample compose file
version: "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 file
version: "3"
services:
  wiremock:
    image: "wiremock/wiremock:latest"
    container_name: my_wiremock
    volumes:
      - ./__files:/home/wiremock/__files
      - ./mappings:/home/wiremock/mappings
    entrypoint: ["/docker-entrypoint.sh", "--global-response-templating", "--disable-gzip", "--verbose"]

References

wiremock-docker's People

Contributors

amir272 avatar bbezanson avatar dependabot[bot] avatar jerosa avatar kapishmalik avatar oleg-nenashev avatar rafearnold avatar rodolpheche avatar tomakehurst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wiremock-docker's Issues

Passing arguments to docker run breaks $JAVA_OPTS

The entry point script does not include $JAVA_OPTS in it, so if you pass arguments to docker run (overriding the CMD in the Dockerfile), $JAVA_OPTS is silently ignored. I think it should be included in the "backup" command in docker-entrypoint.sh as well to prevent this.

Multi-arch / ARM builds

Cloning the repo and building seems to work fine (Apple Silicon) - it'd be great to build the images as multi-arch

JRE7/8 error on SSL certificates

Hello,

I'm trying to use this image as a web proxy for our Selenium integration tests, but I can't get HTTPS proxying to work. I finally traced it down to something odd: visiting http://localhost:8080/__admin/certs/wiremock-ca.crt presents me with a page saying "HTTPS Browser Proxying, including CA certificate retrieval, requires wiremock-jre8". That error seems to be coming from https://github.com/tomakehurst/wiremock/blob/master/java7/src/main/java/com/github/tomakehurst/wiremock/admin/tasks/GetCaCertTask.java, but that's a version 7 build and this image clearly uses version 8. Not sure what's going on here so I figured I'd ask here. Oh and I'm using the rodolpheche/wiremock:2.27.1-alpine image.

Swagger UI is not loading inside the container

Steps to reproduce

  1. Run the container.
    docker run -it --rm -p 8080:8080 rodolpheche/wiremock

  2. Load the Swagger UI in Chrome (or Firefox).
    http://pcname:8080/__admin/swagger-ui/

It takes a minute or so to load the page then it stops without loading any content. In the developer console Chrome prints the following error for each of the CSS and JS files.
"Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH"

Firefox print a more generic "load failing" error.

Direct links to content are:

/__admin/swagger-ui/swagger-ui-dist/swagger-ui.css
/__admin/swagger-ui/swagger-ui-dist/swagger-ui-bundle.js

I have tried a few previous versions of the containers and they behave the same way. Running Wiremock of the same version without the container does not have this problem.

The underlying issue

Those URLs respond using chunked transfer "Accept-Range: bytes" that does not have the "Content-Length" attribute. A lot of garbage binary data is being added to the actual response.

EXPOSE cannot be overridden

I am trying to set up both Wiremock and Traefik for local development, using docker-compose. I'm finding that Traefik will not start because port 8080 is already taken up by Wiremock. I've tried the following configuration for Wiremock, in an attempt to have it not use 8080 at all:

  wiremock:
    image: wiremock/wiremock
    expose:
      - 42020
    ports:
      - '42020: 42020'
    command: '--port 42020'
    volumes:
      - ./services/wiremock:/home/wiremock
CONTAINER ID   IMAGE                                      COMMAND                  CREATED          STATUS                  PORTS                                            NAMES
000012345678   wiremock/wiremock                          "/docker-entrypoint.…"   10 minutes ago   Up 10 minutes           8080/tcp, 8443/tcp, 0.0.0.0:42020->42020/tcp     directory-wiremock-1

Wiremock is in fact available at http://localhost:42020/__admin but when I try to start Traefik I get:

$ docker-compose up --build --detach traefik 
[+] Running 0/1
 ⠙ Container traefik  Starting
Error response from daemon: driver failed programming external connectivity on endpoint traefik (0d9edb76cc2294848c45bed94b0c1bb26082c48e1a5f155f901878e9c5dd065d): Bind for 0.0.0.0:80 failed: port is already allocated

I can try to change the port that Traefik listens as a workaround, but Wiremock is being the noisy neighbor here.

The Dockerfile has EXPOSE 8080 8443 hardcoded. I propose that this be mediated by build args.

Wiremock Extensions

How does one use wiremock extensions with this image? If i mount a volume with the extensions jar how would the docker image pick it up ?

RedHat UBI image

Hi,

I like this image but would like to have a RedHat UBI based image to run on an on-prem Openshift-platform. After a brief look it might be possible to just clone the alpine image and rebase it onto a UBI minimal image.

Multiple extensions

Is there a way to use multiple transformers in '--extensions' option in docker-compose file?
eg: command: java -cp "/var/wiremock/lib/wiremock-jre8-standalone.jar:/home/wiremock/jar/wiremock-extensions-1.0-SNAPSHOT.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --extensions com.my.extension.TransformerFirst com.my.extension.TransformerSecond

Add JRE11 based versions

Would it be possible to add JRE11 based versions?

I see the previously closed PRs about JRE11 (#29, #30 and #31), but there's a valid usecase: extensions. I'm in the process of upgrading a codebase from Java 8 to 11, and it would be sort of messy having to compile the extensions we use with 8 while the main codebase goes to 11 :)

I believe it should be added as new tags, rather than changing latest and latest-alpine to 11 – since Docker added support for ARG in FROM statements, it should be possible to support both 8 and 11 without causing an explosion in the number of Dockerfiles.

There's a couple of potential issues with JRE11, though: there's no Alpine version of OpenJDK 11, so the image would have to based on e.g. AdoptOpenJDK or zulu. And 11 is somewhat larger than 8 – for instance, azul/zulu-openjdk-alpine:11-jre weighs in at 181MB.

JAVA_OPTS global response templating not working

When setting JAVA_OPTS in the Dockerfile, variables are not being picked up. I assume the name of the variable is incorrect but cannot see anywhere what this command line argument translates to.

I have tried a number of variations but no luck. It is fine when using docker-compose as can just add a command parameter but using terraform, this is not the same luxury.

Dockerfile for context:

FROM rodolpheche/wiremock
COPY mappings/mappings.json mappings/mappings.json
ENV JAVA_OPTS="-D-globalResponseTemplating"

Incorrect Version of Wiremock in Docker Images

I noticed with some of the current Docker image releases that the documentation refers to Wiremock version 2.33.x but the images appear to still use version 2.32. I noticed that the Dockerfile and image layers have ENV WIREMOCK_VERSION 2.32.0 set. There are a number of security issues in sub libraries that the 2.33.x version of wiremock fixes. Could somebody take a look a re-release if the above is correct. Thanks

Is it possible to rewrite context root for path routing?

I'm trying to deploy wiremock service in AWS ECS and route /wiremock/* requests to it but all I'm getting is this message, no matter what path I use (even /__admin/):

No response could be served as there are no stub mappings in this WireMock instance.

Is it possible to rewrite/set context root for the service? I've looked at the documentation but failed to find a way of doing it.

How to enable response templating?

Hi Rodolphe, thanks for your docker, it's really useful.

One question: when I run wiremock locally (using the jar) I use --global-response-templating. Is there a way to enable that in your image?

Many thanks and regards,

Jim

Tag: `latest-alpine`

Hey,

This is great, and really useful, but it's be really great to be able to use the latest tag for alpine too? Would you mind adding a latest-alpine tag to Docker hub?

Thanks!

Browser proxy option doesn't seem to work

I'm trying to use this container with the -e WIREMOCK_ARGS="--enable-browser-proxy" flag. Wiremock starts and reports that it does have browser proxying enabled. But the forward proxy doesn't seem to work when wiremock is containerised.

I can get the proxying to work when I use the standalone, but not using this container. Any idea what the issue might be?

Later / Latest version of Java

Hi, thanks for providing this image. It works very nicely for us, recently though we have hit an issue with one of our services that uses this image for testing. The service has been upgraded to enable use of Java 18, however because we also build and compile wiremock transformer classes, when we try to run this image with the transformer classes that have been compiled using java 18 we get the following error when the container tries to start up.

Exception in thread "main" java.lang.UnsupportedClassVersionError: uk/gov/homeoffice/wiremock/refdata/RefDataTransformer has been compiled by a more recent version of the Java Runtime (class file version 62.0), this version of the Java Runtime only recognizes class file versions up to 55.0 at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(Unknown Source) at java.base/java.security.SecureClassLoader.defineClass(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Unknown Source) at com.github.tomakehurst.wiremock.extension.ExtensionLoader$3.apply(ExtensionLoader.java:71) at com.github.tomakehurst.wiremock.extension.ExtensionLoader$3.apply(ExtensionLoader.java:67) at wiremock.com.google.common.collect.Iterators$6.transform(Iterators.java:829) at wiremock.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52) at wiremock.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52) at wiremock.com.google.common.collect.Maps.uniqueIndex(Maps.java:1391) at wiremock.com.google.common.collect.Maps.uniqueIndex(Maps.java:1353) at com.github.tomakehurst.wiremock.extension.ExtensionLoader.asMap(ExtensionLoader.java:40) at com.github.tomakehurst.wiremock.extension.ExtensionLoader.loadExtension(ExtensionLoader.java:32) at com.github.tomakehurst.wiremock.extension.ExtensionLoader.load(ExtensionLoader.java:36) at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.buildExtensions(CommandLineOptions.java:363) at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.<init>(CommandLineOptions.java:354) at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:49) at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:133)

We can resolve the issue by rolling our environment back to Java 11, and we could also look at splitting our transformers in to a separate repo but right now it works quite nicely for us having everything in a single repo.

I would hope it might just be a case of updating this line to something like FROM docker.io/library/eclipse-temurin:18 If so I can have a look at forking the repo to try it out but I wanted to check if there were any plans to issue a docker image tag with java 18 support first before doing so.

Dockerfile uses deprecated java image

From https://hub.docker.com/_/java/:

This image is officially deprecated in favor of the openjdk image, and will receive no further updates after 2016-12-31 (Dec 31, 2016). Please adjust your usage accordingly.

It would be great if this could switch to the new image. Also, can this be switched to use the openjdk:8-jre (309 MB) or openjdk:8-jre-alpine (108 MB)? The 8-jdk image is much bigger (643 MB) and doesn't seem necessary.

Happy to contribute the changes if you think they seem reasonable!

Out of Memory error in thread Connector-Scheduler

I have created a mock server with the following configuration.

DockerFile -


WORKDIR /config
COPY mappings /config/mappings
COPY __files /config/__files

ENV MOCKSERVER_MAPPINGS=/config/mappings
ENV MOCKSERVER_FILES=/config/__files

ENV JAVA_OPTS="-Xms512m -Xmx4g"

CMD ["--global-response-templating", "--max-template-cache-entries", "500"]

docker-compose.yml


services:
  wiremock:
    image: wiremock/wiremock:2.32.0-alpine
    container_name: wiremock_demo
    volumes:
      - ${MOCKSERVER_FILES}:/home/wiremock/__files
      - ${MOCKSERVER_MAPPINGS}:/home/wiremock/mappings
    ports:
      - 8443:8080

But, getting Out of Memory Error quite frequently. Earlier, it was happening on daily basis. But, after setting --max-template-cache-entries to 500, the frequency of this error has reduced.

Screenshot 2022-05-25 at 9 37 04 PM

How to troubleshoot such issues and get more information to trace the cause of this error? Am i missing some config required?

Customize PORT

How do I customize the server PORT in docker-compose?

I tried setting PORT=8181 env but it had no affect.

Changing default port

It's a very simple question, i run:

docker run -it --rm -p 8081:8081 -v $PWD/test:/home/wiremock rodolpheche/wiremock                 
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
 /$$      /$$ /$$                     /$$      /$$                     /$$      
| $$  /$ | $$|__/                    | $$$    /$$$                    | $$      
| $$ /$$$| $$ /$$  /$$$$$$   /$$$$$$ | $$$$  /$$$$  /$$$$$$   /$$$$$$$| $$   /$$
| $$/$$ $$ $$| $$ /$$__  $$ /$$__  $$| $$ $$/$$ $$ /$$__  $$ /$$_____/| $$  /$$/
| $$$$_  $$$$| $$| $$  \__/| $$$$$$$$| $$  $$$| $$| $$  \ $$| $$      | $$$$$$/ 
| $$$/ \  $$$| $$| $$      | $$_____/| $$\  $ | $$| $$  | $$| $$      | $$_  $$ 
| $$/   \  $$| $$| $$      |  $$$$$$$| $$ \/  | $$|  $$$$$$/|  $$$$$$$| $$ \  $$
|__/     \__/|__/|__/       \_______/|__/     |__/ \______/  \_______/|__/  \__/

port:                         8080 <<<<<<<<<<<< Notice that the port is the same
enable-browser-proxying:      false
disable-banner:               false
no-request-journal:           false
verbose:                      false

Is it possible to customize it?

Thanks

Provide Docker images for WireMock 3.0

Proposal

Currently we have no official images for WireMock 3.x. It would be great to add them. Note that WireMock 3 is not fully compatible, but there should be no issues with the current CLIs and Extension logic used by the Docker image

NOTE: The experimental WireMock 3.x images are available for evaluation: wiremock/wiremock:3x and wiremock/wiremock:3x-alpine! Now they package 3.0.0-beta-13 and, hopefully, integrate all the breaking changes in the structure. The images work with Testcontainers Java, Python and Golang, as long as you update the configuration files if any breaking change affects you. Soon I plan to cut the Java 17 images too after the necessary integration tests and configurations are in place. Meanwhile, any feedback will be appreciated!

References

Skip the use of gosu library

Several vulnerabilities exist in this image because of outdated Go version in gosu library. Especially CVE-2022-23806 and CVE-2021-38297 are critical and can be fixed only if gosu updates their Go version, as they are far behind now (1.14). There is an open issue in gosu but it has been there for more than a month.

My question is, do we really need to use gosu? I do not see that much value, especially if this library adds CVEs in our systems.
Can we maybe have a version that does NOT use gosu library?

Thanks in advance

When setup as proxy failing in Docker mode but not standalone

Hi,

I have a standalone wiremock with an extension that I am able to setup with stubs to act as a proxy for specific https requests, it forwards them on to the real server and uses my extension to modify the response using regex changes. This all works and my browser gets the responses and is happy.

When I run the same logic in wiremock docker the browser marks the request as failed but swagger shows a 200 response being returned with the body I expect. I then used curl to confirm everything was as expected however it fails as well with the following reason. I'm at a loss to know why this is happening only when running in docker. Any idea's ?

I am running using the following command:

docker run -it --rm -p 18443:8443 webby/wiremock --https-port 8443 --disable-gzip=true --extensions com.mystuff.BodyTransformer

  • Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
  • http2 error: Invalid HTTP header field was received: frame type: 1, stream: 1, name: [transfer-encoding], value: [chunked]
  • HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
  • stopped the pause stream!
  • Connection #0 to host localhost left intact
    curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
  • Closing connection 0

looking for a FIX for CVE-2022-42889

In the docker file for creation of nightly or main branch it always uses the tag 2.34.0
so there is no latest changes from the merged main branch reflected in the nightly
effectively all the builds (nightly, main, 2.34) all of them create the same docker image.

i am here looking for the fix of [CVE-2022-42889] and it is available in the main branch but the docker build uses only 2.34.0 in all the builds
could you update the nightly-alpine docker file to use master branch?

Error running 2.16.0 in docker compose

I'm getting

ERROR: readlink /var/lib/docker/overlay2/l: invalid argument

When I'm using latest (2.16.0) from docker compose. I reverted to 2.15.0 and this seems to have resolved the issue.

I'm using Arch Linux and Docker version 18.03.0-ce, build 0520e24302

Thanks

logging incoming request

Hi!

Is there any chance to logging to stdout (or file) every incoming request with the data?

Thanks for the response in advance!

Greg

Using docker-compose to start image

docker-compose doesn't yet support passing arguments to the entrypoint script. That means that this image can't be launching using docker-compose. Can the arguments be converted to environment variables?

Move documentation to the project's repository

Summary

Currently we have duplication of docs between README and the project's website, and I doubt it would be good in the future. To avoid consistency issues, I would propose to follow the documentation-as-code approach and put all the image-specific documentation under the repository, and just have a bare minimum on the website. Later we can implmenet importing documentation from the repository to the website.

References

Logging to stdout missing

Hello, and thank you for your docker wiremock container!

When starting wiremock, I get this warning:

wiremock_1  | SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
wiremock_1  | SLF4J: Defaulting to no-operation (NOP) logger implementation
wiremock_1  | SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

I think it should be sufficient to add logback-classic to the classpath. Configuration should not be necessary. Just in case someone wants to modify logging, you could add this JVM parameter:
-Dlogback.configurationFile or -Dlogging.config.

Thanks in advance!

Hot reloading of mappings

Wiremock itself doesn't contain functionality to automatically reload mappings if they change on the file system.

However, there is an endpoint POST __admin/mappings/reset to reload mappings on demand.

This could be used in two ways to trigger reloading:

  1. Run a shell script with a configurable refresh interval that POSTs to that endpoint
  2. Run an inotify-check shell script that fires a POST to that endpoint whenever the mappings folder changes.

Our use case for this is that we are using the container in a local dev environment, and the mappings folder is a bind mount into the container. Would you be interested in either of those possibilities being included in the docker images (would require to install inotify-tools and curl, or just curl if the interval method is used).

Currently, we just launch an additional container in our compose file that hits the endpoint every few seconds:

FROM alpine:3.12.0
RUN apk add --no-cache curl
CMD while true; do sleep 5; curl -XPOST http://wiremock:8080/__admin/mappings/reset; done

404 error

Hey there!

Today I have started face a strange behaviour: all requests to mapping endpoints started throw a 404:

<html><head>
<title>JBWEB000065: HTTP Status 404 - </title>
<style>
<!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76
;}
-->
</style>
</head><body>
<h1>JBWEB000065: HTTP Status 404 - </h1>
<HR size="1" noshade="noshade">
<p><b>JBWEB000309: type</b> JBWEB000067: Status report</p>
<p><b>JBWEB000068: message</b> <u></u></p>
<p><b>JBWEB000069: description</b> <u>JBWEB000124: The requested resource is not available.</u></p>
<HR size="1" noshade="noshade">
</body></html>

Have you ever seen this message? How can I solve it?

Expose port 80,443 instead of 8080,8443 and allow docker run command to override if need be

Hi, excellent docker image by the way got it up and running quickly, however, I was wondering if its possible to expose ports 80 and 443 instead of 8080 and 8443 and allow the user running the docker image to then specify a mapping if need be.

The reason is I want to run this in an azure container and it does not allow me to change the mapping at all so defaults to 80 and it does not map down....

I know wire mock can be run on different ports than the default, I am not a bash expert so cannot see where to tweak the entry point file..?

Thanks for any assistance :-)

John

Question regarding running extension within docker

Can you please help? The bellow example works fine when using version 1.1.3 but it does not work when using version 1.1.6.. Can you please let me know what i am missing?

Thanks!

FROM rodolpheche/wiremock

COPY stubs /home/wiremock

ADD https://repo1.maven.org/maven2/com/opentable/wiremock-body-transformer/1.1.3/wiremock-body-transformer-1.1.3.jar /var/wiremock/extensions/

CMD ["--extensions", "com.opentable.extension.BodyTransformer"]

When trying to execute /random request example using 1.1.6 it gives me. If i execute this using version 1.1.3 everything works fine

`HTTP ERROR 500
Problem accessing /random. Reason:

Server Error

Caused by:
java.lang.IllegalArgumentException: urlRegex' not present
at wiremock.com.google.common.base.Preconditions.checkArgument(Preconditions.java:141)
at com.github.tomakehurst.wiremock.common.Metadata.checkKeyPresent(Metadata.java:88)
at com.github.tomakehurst.wiremock.common.Metadata.checkPresenceValidityAndCast(Metadata.java:73)
at com.github.tomakehurst.wiremock.common.Metadata.getString(Metadata.java:53)
at com.opentable.extension.BodyTransformer.transform(BodyTransformer.java:112)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.applyTransformations(InMemoryStubMappings.java:100)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:79)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:179)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:50)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:47)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at wiremock.org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:753)
at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:502)
at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
at wiremock.org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at wiremock.org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at wiremock.org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:132)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)
`

Nightly build

Hi are there any plans for the nightly tagged image to be a nightly build of Wiremock? Please correct me if I'm wrong but it looks like it's the same version of Wiremock as main / latest tagged images provide.

Deploy images to GitHub Container Registry too

With all the recent Docker pricing drama and download rate limits for unregistered users & free plans, I think it would be nice to also automate deployments to GitHub Container Registry as a secondary mirror. It can be easily done via GitHub Actions

Reset wiremock takes too long

Hello!

We are using the latest docker image of wiremock, for testing a react web application.
We have noticed that when we use the __admin/mappings/reset or __admin/reset to reset wiremock the response of success takes almost 5 to 6 seconds. We have tried different endpoints to reset using http://localhost:{port} or http://172.17.0.1:{port}. We got in the container and we run a curl command to reset the wiremock curl -X POST 'http://172.17.0.1:{port}/__admin/mappings/reset' and again we count around 5 secs. In standalone wiremock we noticed that those actions take ms to complete. The scale of our wiremock counts 283 mappings.

Have you seen such an issue before?
Thank you in advance!

Arguments for Wiremock

Hi,

I am trying to tie this together with another service, which I want to use to fetch some fake config data for testing.

However, I'm using docker-compose and I can't figure out how to use --record-mappings --verbose (or any other runtime argument)

I can see that you are running the actual wiremock.jar file here: https://github.com/rodolpheche/wiremock-docker/blob/master/Dockerfile#L32 (or maybe here: https://github.com/rodolpheche/wiremock-docker/blob/master/docker-entrypoint.sh#L7)

Would it be possible for you to add a new ENV_VAR, i.e. - WIREMOCK_OPTS to make this a bit more configurable and usable in docker-compose ?

I'd like to contribute, otherwise, I'll just have to do YET ANOTHER FORK :P

Thanks :)

Improve image extendability

Hello!

I just found your docker image and I like it a lot. However, I need to integrate it into a CI where I won't be able to mount volumes with my stubs and extensions for what I want to do. So I plan on extending your image. If that poses no issue for the stubs, it does for extensions as I can add them to the image but not add the "--extensions" to the existing command or entrypoint without overwriting them.

Could it be possible to add an option of providing args to the existing command and entrypoint when extending your image? Maybe simply by adding an environment variable WIREMOCK_ARGS (like JAVA_OPTS) to append at the end of the command and entrypoint?

Can not record with wiremock

I am asking it hire because I have no idea where else should I ask it.

I have created next docker-compose.yml file:
version: '3.1' services: wordpress_test: container_name: wp_test restart: always image: wordpress depends_on: - db_test links: - wiremock_wp:wiremock ports: - 8989:80 environment: WORDPRESS_DB_HOST: db_test:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress tty: true db_test: container_name: wp_test_db restart: always image: mysql:5.7 ports: - "3306" environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wiremock_wp: container_name: wp_wiremock image: rodolpheche/wiremock ports: - 8283:8080 - 8484:8443

Then i added the hello.json files to the wiremock directory and after restart all is working accessing http://localhost:8283/hello I get "the __files/hello.json" output. But when I am trying to record the http://localhost:8283/hello request with http://localhost:8283/__admin/recorder/ I get next error:

Problem accessing /hello. Reason: Server Error Caused by: java.lang.RuntimeException: wiremock.org.apache.http.conn.HttpHostConnectException: Connect to localhost:8283 [localhost/127.0.0.1] failed: Connection refused (Connection refused) at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.render(ProxyResponseRenderer.java:87) at com.github.tomakehurst.wiremock.http.StubResponseRenderer.buildResponse(StubResponseRenderer.java:57) at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:51) at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:47) at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at wiremock.org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479) at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:499) at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258) at wiremock.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:748) Caused by: wiremock.org.apache.http.conn.HttpHostConnectException: Connect to localhost:8283 [localhost/127.0.0.1] failed: Connection refused (Connection refused) at wiremock.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159) at wiremock.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) at wiremock.org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at wiremock.org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at wiremock.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at wiremock.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.render(ProxyResponseRenderer.java:71) ... 21 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at wiremock.org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75) at wiremock.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) ... 30 more Caused by: wiremock.org.apache.http.conn.HttpHostConnectException: Connect to localhost:8283 [localhost/127.0.0.1] failed: Connection refused (Connection refused) at wiremock.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159) at wiremock.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) at wiremock.org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at wiremock.org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at wiremock.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at wiremock.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.render(ProxyResponseRenderer.java:71) at com.github.tomakehurst.wiremock.http.StubResponseRenderer.buildResponse(StubResponseRenderer.java:57) at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:51) at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:47) at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at wiremock.org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479) at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:499) at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258) at wiremock.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:748) Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at wiremock.org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75) at wiremock.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) ... 30 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at wiremock.org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75) at wiremock.org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) at wiremock.org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) at wiremock.org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) at wiremock.org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) at wiremock.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) at wiremock.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) at wiremock.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56) at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.render(ProxyResponseRenderer.java:71) at com.github.tomakehurst.wiremock.http.StubResponseRenderer.buildResponse(StubResponseRenderer.java:57) at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:51) at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:47) at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at wiremock.org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479) at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:499) at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258) at wiremock.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:748)

What is different when I accesing the http://localhost:8283/hello url if I am not recording and when I am recording? What might cause the error? How can I debug or get more information about the error cause?

2.32.0 missing SLF4J implementation

It appears both the debian-based and alpine-based container images are missing an SLF4J logger implementation on the classpath.

I understand that the non-standalone JAR of WireMock does not contain an implementation of SLF4J, but that the standalone JAR should. I assume the standalone JAR should be the one being used in this image, so I am not entirely sure what is going on.

Reproduction steps

Debian

  1. Run docker run -it --rm wiremock/wiremock:2.32.0 --verbose
  2. Observe the error in the output:
$ docker run --rm -it wiremock/wiremock:2.32.0 --verbose

2022-06-07 17:11:03.371 Verbose logging enabled
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2022-06-07 17:11:04.138 Verbose logging enabled
 /$$      /$$ /$$                     /$$      /$$                     /$$
| $$  /$ | $$|__/                    | $$$    /$$$                    | $$
| $$ /$$$| $$ /$$  /$$$$$$   /$$$$$$ | $$$$  /$$$$  /$$$$$$   /$$$$$$$| $$   /$$
| $$/$$ $$ $$| $$ /$$__  $$ /$$__  $$| $$ $$/$$ $$ /$$__  $$ /$$_____/| $$  /$$/
| $$$$_  $$$$| $$| $$  \__/| $$$$$$$$| $$  $$$| $$| $$  \ $$| $$      | $$$$$$/
| $$$/ \  $$$| $$| $$      | $$_____/| $$\  $ | $$| $$  | $$| $$      | $$_  $$
| $$/   \  $$| $$| $$      |  $$$$$$$| $$ \/  | $$|  $$$$$$/|  $$$$$$$| $$ \  $$
|__/     \__/|__/|__/       \_______/|__/     |__/ \______/  \_______/|__/  \__/

port:                         8080
enable-browser-proxying:      false
disable-banner:               false
no-request-journal:           false
verbose:                      true

Alpine

  1. Run docker run -it --rm wiremock/wiremock:2.32.0-alpine --verbose
  2. Observe the error in the output:
$ docker run --rm -it wiremock/wiremock:2.32.0-alpine --verbose

2022-06-07 17:14:19.608 Verbose logging enabled
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2022-06-07 17:14:20.223 Verbose logging enabled
 /$$      /$$ /$$                     /$$      /$$                     /$$
| $$  /$ | $$|__/                    | $$$    /$$$                    | $$
| $$ /$$$| $$ /$$  /$$$$$$   /$$$$$$ | $$$$  /$$$$  /$$$$$$   /$$$$$$$| $$   /$$
| $$/$$ $$ $$| $$ /$$__  $$ /$$__  $$| $$ $$/$$ $$ /$$__  $$ /$$_____/| $$  /$$/
| $$$$_  $$$$| $$| $$  \__/| $$$$$$$$| $$  $$$| $$| $$  \ $$| $$      | $$$$$$/
| $$$/ \  $$$| $$| $$      | $$_____/| $$\  $ | $$| $$  | $$| $$      | $$_  $$
| $$/   \  $$| $$| $$      |  $$$$$$$| $$ \/  | $$|  $$$$$$/|  $$$$$$$| $$ \  $$
|__/     \__/|__/|__/       \_______/|__/     |__/ \______/  \_______/|__/  \__/

port:                         8080
enable-browser-proxying:      false
disable-banner:               false
no-request-journal:           false
verbose:                      true

Feature request: Drop `VOLUME` definition from `wiremock/wiremock` image

I was very pleased to learn that Wiremock now provides it's own official docker image 🎉

We used our own custom wiremock docker image the last few years, which started out from a fork of the rodolpheche/wiremock docker image (probably just the same as the official image). I now tried to use the official image as a drop-in replacement for our own wiremock base image.

But it turns out there is one crucial difference we added to our own docker image: We deliberately dropped the VOLUME /home/wiremock definition from the Dockerfile.

The reason is that we have derived images from that are purpose-built to mock some specific API each, and to update those (in a CI/CD environment, not locally) the image build just copies the updated mock files into those images as part of the build process. This of course breaks when the image itself already defines a VOLUME for those files, as the old state will be retained on the hosts when the new image version is deployed.

Of course there are ugly hacks and workarounds (like reconfiguring the upstream image to use a different home folder, copy the files to this new home folder instead, then using a tmpfs volume for the now-useless /home/wiremock volume etc) - but all this is not needed to start with, as IMHO there is no upside in defining that VOLUME in your Dockerfile but it creates a lot of problems.

Brandon Mitchell has written a short, clear (and more literate) summary of the pros and cons than I could: https://boxboat.com/2017/01/23/volumes-and-dockerfiles-dont-mix/

Would it be possible to drop that VOLUME /home/wiremock definition from your image?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.