连接到Docker容器内运行的GRPC服务器

我想尝试从主机上的Docker容器中运行GRPC服务器。 我想看看是否可以通过在“主机”networking模式下运行来获得更好的性能。 我从java开始

CreateContainerResponse container = dockerClient.createContainerCmd("darthshana/lostvictoryserver:0.0.1-SNAPSHOT") .withVolumes(volume1) .withBinds(new Bind("/home/darthshana/gameEngine/lostVictoriesServer.properties", volume1)) .withExposedPorts(tcp5055) .withPortBindings(portBindings) .withNetworkMode("host") .withEnv("GAME_NAME="+gameName, "GAME_PORT=5055") .exec(); 

这会导致以下泊坞窗容器启动

 docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b982b240ada2 darthshana/lostvictoryserver:0.0.1-SNAPSHOT "/usr/bin/java -ja..." About a minute ago Up About a minute angry_curie 

在主机上,我可以看到它已经暴露了正确的端口

 Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp6 0 0 :::5055 :::* LISTEN - 

我在主机上有一个防火墙规则

 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:5055 state NEW 

它允许我从外面连接到GRPC服务器。而且一切都很好! 然而….出于某种原因,我无法连接到同一主机内的grpc服务器..哪个即时通讯要做的从主机上运行的另一个java进程本身(而不是docker集装箱)..我试过

  ManagedChannel managedChannel = ManagedChannelBuilder.forAddress("......", game.getPort()) .usePlaintext(true) .build(); 

在“……”string本地主机,127.0.0.1,也是我从外部主机成功使用的服务器的外部IP ..但他们都不工作,GRPC调用,但它从来没有达到grpc服务器,并不返回..我没有得到任何错误。 但是,如果我杀了泊坞窗容器,我得到的错误

 2017-10-12 19:03:29.484 ERROR 3366 --- [io-8080-exec-10] oaccC[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is io.grpc.StatusRuntimeException: INTERNAL: Connection closed with unknown cause] with root cause io.grpc.StatusRuntimeException: INTERNAL: Connection closed with unknown cause at io.grpc.stub.ClientCalls.toStatusRuntimeException (ClientCalls.java:210) ~[grpc-stub-1.6.1.jar!/:1.6.1] 

它的连接是成功的,但通话没有通过。 我已经尝试从外部主机到docker中运行相同的grpc服务器相同的确切的调用,它工作正常。

为什么我不能从本地主机连接到它? 任何指导将不胜感激