Docker host rmi throws invalid authority but able to ping

五迷三道 提交于 2019-12-13 04:04:57

问题


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 

回答1:


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


来源:https://stackoverflow.com/questions/50668938/docker-host-rmi-throws-invalid-authority-but-able-to-ping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!