碰到Docker容器时对等连接重置

碰到Docker容器时对等连接重置

本文介绍了碰到Docker容器时对等连接重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了问题,无法将网络请求发送到我创建的Docker容器。我已经暴露了正确的端口,所以我不确定这里可能还有其他问题。

I'm having a problem, where I can't send network requests to a Docker container I've created. I've exposed the correct ports, so I'm not sure what other issues could be at fault here.

我有一个服务器在 alice 的容器中运行,该容器位于 localhost:10009

I have a server running in container alice at localhost:10009:

$ docker exec -it alice bash
bash-4.4# curl localhost:10009
curl: (52) Empty reply from server

端口10009暴露从我的容器中:

Port 10009 is exposed from my container:

$ docker port alice
10009/tcp -> 0.0.0.0:10009

当执行相同的 curl 从主机上收到一条不同的消息:

When doing the same curl from my host machine I get a different message:

$ curl localhost:10009
curl: (56) Recv failure: Connection reset by peer


重新设置连接

推荐答案

我将检查服务器应用程序是否配置为仅侦听来自其 localhost的请求,此检查取决于未使用的服务器类型。

I would check to see if the server application is configured to only listen to requests coming from its "localhost", this check depends on the type of server that you're using which is not mentioned.

一个简单的检查方法如下:

an easy check is to start your container as follows:

docker run --network host -d yourimagename

您不必担心端口映射,因为'使用主机网络

You don't need to worry about port mapping since you're using the host network

然后尝试卷曲,如果可行,那么您只需要查看服务器的监听IP设置。

then try to curl, if that works, then you'll just need to review your server listening IP setting.

curl localhost:10009

这篇关于碰到Docker容器时对等连接重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 23:59