客户端和服务器应用程序无法在容器和主机上进行通信?

问题描述 投票:0回答:1

我有一个客户端和服务器应用程序。服务器侦听TCP localhost:3344地址,客户端发送消息给localhost:3344。在同一主机上运行它们时工作正常。

如果服务器在docker容器上运行且客户端在主机上运行,​​则服务器不会收到任何消息。不知道如何设置网络,以便容器侦听主机的localhost。我尝试以下方法:

docker run -it --expose 3344 -p 127.0.0.1:3344:3344 run-server
docker networking
1个回答
1
投票

这只会为你做的工作:

docker run -it -p 3344:3344 <docker repository name> run-server
© www.soinside.com 2019 - 2024. All rights reserved.