【问题标题】:curl (56) Recv failure: Connection reset by peer - when hitting docker containercurl (56) Recv failure: Connection reset by peer - 当点击 docker 容器时
【发布时间】:2018-05-03 12:24:13
【问题描述】:

curl 应用程序 ip 时出现此错误

curl (56) Recv failure: Connection reset by peer - when hit docker container

【问题讨论】:

    标签: docker curl port dockerfile


    【解决方案1】:

    通过运行做一个小检查:

    docker run --network host -d <image>
    

    如果curl 在此设置下运行良好,请确保:

    1. 您正在正确地将主机端口映射到容器的端口:
    docker run -p host_port:container_port <image>
    
    1. 您的服务应用程序(在容器中运行)在localhost0.0.0.0 上运行而不是类似127.0.0.1

    【讨论】:

      【解决方案2】:

      我遇到了同样的错误

      umesh@ubuntu:~/projects1$ curl -i localhost:49161

      curl: (56) Recv failure: Connection reset by peer

      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

      在我的情况下,这是由于错误的端口没有

      |---我的项目--我的工作文件夹

      --------|Dockerfile ---端口定义为 8080

      --------|index.js-----端口定义3000

      --------|package.json

      然后我正在运行 :::: docker run -p 49160:8080 -d umesh1/node-web-app1

      所以当应用程序在 index.js 中的端口 3000 中运行时,它无法连接到应用程序,因为你得到了错误

      解决问题

      删除了在我的worong端口创建的最后一个容器/图像

      只需更改 INDEX.JS 的端口号

      |---我的项目--我的工作文件夹

      --------|Dockerfile ---端口定义为 8080

      --------|index.js-----端口定义8080

      --------|package.json

      然后构建新图像

      docker build -t umesh1/node-web-app1 .
      

      使用暴露端口以守护程序模式运行映像

      docker run -p 49160:8080 -d umesh1/node-web-app1

      因此我的应用程序正在运行,并且端口 49161 上没有任何错误列表

      【讨论】:

        【解决方案3】:

        当绑定到容器内的任何服务都没有 lissened 的端口时,我也有同样的情况。 所以检查-p选项

        -p 9200:9265
        -p <port in container>:<port in host os to be binded to>
        

        【讨论】:

          猜你喜欢
          • 2014-12-20
          • 2021-05-11
          • 2021-09-06
          • 1970-01-01
          • 2012-07-15
          • 2019-09-06
          • 1970-01-01
          • 2019-06-11
          • 2020-06-06
          相关资源
          最近更新 更多