【问题标题】:docker-machine - unable to connect to rest urldocker-machine - 无法连接到休息网址
【发布时间】:2020-01-18 16:38:11
【问题描述】:

我在本地的 docker setup 中运行一个应用程序 [在 Mac 中使用 homebrew 安装了 docker]。

我从邮递员那里得到Could not get any response,或者在 curl 电话中得到Empty reply from server

我尝试了docker-machine: Can't access container's web server from host 中提到的所有解决方案,但没有一个对我有用。我不知道为什么我无法访问该 URL。

我正在附加 docker ps 和 docker-machine env 输出。

我还附上了我的 docker-compose.yml

version: '3.2'
services:
  details:
    image:  localhost:5000/my-details-1
    container_name: details
    #build: ./details
    expose:
      - 9080
  ratings:
    image: localhost:5000/my-ratings-1
    container_name: ratings
    #build: ./ratings
    expose:
      - 9080
  reviews:
    image: localhost:5000/my-reviews-1
    container_name: reviews
    #build: ./reviews/reviews-wlpcfg
    expose:
      - 9080
  restwrapjdbc:
    image: localhost:5000/my-restwrapjdbc
    container_name: restwrapjdbc
    #build: ./RestWrapJDBC
    expose:
      - 8085
  mirest:
    image: localhost:5000/my-mirest
    container_name: mirest
    #build: ./MIRest
    #network_mode: "host"
    expose:
      - 8085
    ports:
      - target: 8085
        published: 8085
        protocol: tcp
        mode: hosts

已编辑:

我忘记包含来自web.xmlurl-pattern。将该字符串包含到 url 中有效。

【问题讨论】:

  • 我无法运行那个docker-compose.yml 文件;看起来您附加了图像而不是文件的实际内容。能不能把这两张截图删掉替换掉?

标签: docker docker-compose docker-machine


【解决方案1】:

您的端口映射错误。似乎您的图像公开了端口 8080。但是您将 8085 映射到 8085。

改为:

expose:
      - 8085
ports:
      - target: 8085
        published: 8085
        protocol: tcp
        mode: hosts

ports:
      - 8085:8080

【讨论】:

  • 当我运行 curl http://localhost:8085/ -> HTTP Status 404 – Not Found curl http://192.168.99.101:8085/ -> connection refused. 时,在您建议的更改后出现以下错误
  • curl http://localhost:8085/ HTTP Status 404 这意味着你的 docker 现在响应了!您必须添加正确的路径。
  • 您还可以检查您的应用在容器内的响应方式。只需执行:docker exec -it mirest /bin/bash 现在您可以检查 curl 到容器内的 localhost。
  • 静止状态 404-未找到。
  • 你更新你的路径了吗?您的 REST api 在开发环境中如何响应?
猜你喜欢
  • 2016-05-24
  • 1970-01-01
  • 2019-07-11
  • 2016-04-23
  • 2016-05-30
  • 2018-01-21
  • 1970-01-01
  • 2021-01-12
  • 2018-08-10
相关资源
最近更新 更多