itgeek
itgeek

Reputation: 589

Docker Container with Wiremock could not find stub mappings

Link to the Repo:https://github.com/wiremock/wiremock-docker

I'm getting an error when I try to access stubs, not sure if I'm missing anything here. Can I know if the below command is correct ?

docker run --rm -d -p 8080:8080 -p 8443:8443 --name wiremock_demo \
  -v $PWD:/home/wiremock \
  rodolpheche/wiremock:2.25.1

enter image description here

ERROR:

enter image description here

enter image description here

Upvotes: 1

Views: 5603

Answers (1)

Mesut GUNES
Mesut GUNES

Reputation: 7421

The mapping should be made to $PWD:/home/wiremock/mappings where PWD has the json files.

Also json files should look like this:

{
  "mappings": [
    {
      "id": "679dd3ce-55e5-45ee-b270-01dcf1b371ca",
      "request": {
        "urlPattern": "^/hello",
        "method": "GET"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "status": "success",
          "message": "Hello"
        },
        "headers": {
          "Content-Type": "text/plain"
        }
      },
      "uuid": "679dd3ce-55e5-45ee-b270-01dcf1b371ca"
    },
    {
      "id": "679dd3ce-55e5-45ee-b270-01dcf1b371c2",
      "request": {
        "urlPattern": "^/hello-2",
        "method": "GET"
      },
      "response": {
        "status": 200,
        "jsonBody": {
          "status": "success",
          "message": "Hello-2"
        },
        "headers": {
          "Content-Type": "text/plain"
        }
      },
      "uuid": "679dd3ce-55e5-45ee-b270-01dcf1b371c2"
    }
  ]
}

if you are running it json request object then the mapping should provide the mappings and the __files so need to map the containing folder:

docker run -it --rm \
  -p 8090:8080 \
  -v $PWD/samples/hello/stubs:/home/wiremock \
  wiremock/wiremock

enter image description here

Upvotes: 2

Related Questions