Docker 带有 Wiremock 的容器找不到存根映射

Docker Container with Wiremock could not find stub mappings

Link 到回购:https://github.com/wiremock/wiremock-docker

我在尝试访问存根时遇到错误,不确定我是否遗漏了任何内容。我能知道下面的命令是否正确吗?

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

错误:

应该映射到 $PWD:/home/wiremock/mappings,其中 PWD 有 json 个文件。

另外 json 个文件应如下所示:

{
  "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"
    }
  ]
}

如果你是 运行 它 json 请求对象那么映射应该提供 mappings__files 所以需要映射包含的文件夹:

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