Spring&Docker:RMI主机名解析为0.0.0.0,而不是其预期的IP地址

我目前正在开发一个将Docker和Spring程序与RMI服务相关联的项目,而我找不到解决问题的方法。

我试图通过docker-compose.yml文件将两个Spring程序部署到两个不同的容器中。 第一个暴露了地址为0.0.0.0 (全部)的RMI接口以及特定的端口(在Docker文件中也是EXPOSEd)。 而第二个只是一个使用远程接口的RMI客户端。

为了访问公开RMI服务的容器,我通过Compose文件中的links参数给它一个别名,如下所示:

 services: rmi-service: ... rmi-client: ... links: - rmi-service:rmihost 

当我用docker-compose up -d启动我的容器时,如果我从第二个容器执行命令ping rmihost ,它工作的很好。 但是当我尝试启动我的Spring RMI客户端时,出现以下错误:

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'my.rmi.client' defined in class path resource [META-INF/rmi-client-spring.xml]: Invocation of init method failed; nested exception is org.springframework.remoting.RemoteConnectFailureException: Could not connect to remote service [rmi://rmihost:11199/businessService]; nested exception is java.rmi.ConnectException: Connection refused to host: 0.0.0.0 

我无法弄清楚为什么它不能将主机名转换成正确的IP地址,而我可以ping它。 我尝试在/etc/hosts文件中添加rmihost ,但是它不会改变任何东西,它总是给出相同的错误。

任何帮助或建议,在这个问题将不胜感激! 提前致谢!

编辑这里是我docker-compose.yml文件:

 version: '2.1' services: rmi-service: restart: always tty: true build: ./rmi-service/ image: rmi-service container_name: rmi-service expose: - "11199" rmi-client: restart: always tty: true build: ./rmi-client/ image: rmi-client container_name: rmi-client depends_on: - rmi-service links: - rmi-service:rmihost