Docker主机RMI抛出无效权限但可以Ping [英] Docker host rmi throws invalid authority but able to ping
问题描述
我有Alfresco,它在一个Docker容器A上运行,并在说33333 上公开了rmi。另一个普通的Java服务在容器B上运行。两者都连接到相同的自定义网桥网络。
当容器B尝试使用URL rmi:// alfresco:33333
通过rmi通过rmi连接到露天餐厅时,它会抛出 java.net.MalformedURLException:无效权限:rmi:// alfresco:33333 / Abcdefghi
。但是同样可以在户外进行 ping操作。我认为rmi中给出的url格式是错误的。如果是这样的话。应该用什么代替?我已经尝试过
alfresco
, alfresco.abc
。但是仍然存在相同的错误。
否则我是否在 docker-compose
文件中丢失了某些内容?
这是两个撰写文件的示例配置。
Alfresco(容器A) :
版本: 3
服务:
露天:
图像:xxxxxxx:最新
container_name:露天
公开:
- 33333
端口:
-xxxx:xxxx
网络:
默认值:
外部:
名称:test
< blockquote>
服务(容器B):
版本: 2.2
服务:
abc:
图片:openjdk:8-jre-slim
working_dir:/ home
入口点:java- jar ABC.jar
网络:
默认值:
外部:
名称:test
找出原因。 RMI需要IP地址或有效域。由于 alfresco
可通过服务发现获得,并且ping将其重新分配,因此RMI认为它是无效的URL。因此,我必须以有效的网址格式为露天主机提供别名。
我给了一个叫 alfresco.local
的别名,现在它可以正常工作了。
这是我修改过的户外Compose文件:
露天(容器A)
版本:' 3'
服务:
露天:
图片:xxxxxxx:最新
container_name:露天
网络:
默认值:
别名:
-alfresco.local#以某种有效的DNS格式指定别名
公开:
- 33333
端口:
-xxxx:xxxx
网络:
默认值:
外部:
名称:test
I've Alfresco, Running on one docker container A and exposes rmi on say 33333. Another normal java service runs on container B. Both are connected to same custom bridge network.
When container B tries to connects to alfresco via rmi using url rmi://alfresco:33333
it throws java.net.MalformedURLException: invalid authority: rmi://alfresco:33333/Abcdefghi
. But the same is able to ping
alfresco. I think the url format given in rmi is wrong. if so. What should it be substituted with? I already tried alfresco
,alfresco.abc
. but same error persists.
Or else am I missing something in docker-compose
file?
Here is the sample configuration of both compose files.
Alfresco (Container A):
version: '3'
services:
alfresco:
image : xxxxxxx:latest
container_name : alfresco
expose:
- "33333"
ports:
- xxxx:xxxx
networks:
default:
external:
name: test
Service (Container B):
version: '2.2'
services:
abc:
image: openjdk:8-jre-slim
working_dir: /home
entrypoint: java -jar ABC.jar
networks:
default:
external:
name: test
Found out the reason. RMI is expecting either IP address or a valid domain. Since alfresco
is available via service discovery and ping recogonises it, RMI assumes it to be an invalid URL. Hence I've to give an alias for alfresco host in a valid url format.
I gave an alias called alfresco.local
now it works fine.
Here is my modified Compose file for alfresco:
Alfresco (Container A)
version: '3'
services:
alfresco:
image : xxxxxxx:latest
container_name : alfresco
networks:
default:
aliases:
- alfresco.local #specify an alias in some valid DNS format
expose:
- "33333"
ports:
- xxxx:xxxx
networks:
default:
external:
name: test
这篇关于Docker主机RMI抛出无效权限但可以Ping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!