如何将RMI从Docker容器连接到外部服务器?

时间:2019-07-18 10:01:22

标签: docker external rmi

我正在尝试通过RMI通过Docker容器联系外部服务器。 我的容器webapp2需要在docker-compose外部与一个Servur通信。

我正在将docker-compose与多个容器(nginx,webapp1,webapp2,bdd,springcloud)一起使用 我的外部服务器上的RMI端口:1099 我尝试使用: -telnet myServerIp 1099

那是回报:

root@449de39c800f:/usr/local/tomcat# telnet 192.168.1.173 1099  
Trying 192.168.1.173...  
Connected to 192.168.1.173.  
Escape character is '^]'.

这是我的docker-compose.yml

version: '3'
services:
  cnginx:
    image: cnginx
    ports:
      - 80:80
    restart: always
    depends_on:
      - webapp1
      - configproperties
      - webapp2
      - initcontainer
  db:
    container_name: db
    image: postgres:9.3
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: admin
    restart: always
    command:
      - -c
      - max_prepared_transactions=100
  webapp1:
    image: webapp1
    restart: on-failure:2
    depends_on:
      - db
    expose:
      - "8080"
    volumes:
      - app-volume:/tmp/cprocess:rw
  initcontainer:
    image: initcontainer
    restart: on-failure:2
    depends_on:
      - webapp1
  configproperties:
    restart: on-failure:2
    image: configproperties
    depends_on:
      - initcontainer
    expose:
      - "8085"
    environment:
      - SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/cprocess?currentSchema=public
  webapp2:
    restart: on-failure:2
    image: webapp2
    environment:
      - SPRING_CLOUD_CONFIG_URI=http://configproperties:8086/config-server
      - SPRING_PROFILES_ACTIVE=docker
      - CATALINA_OPTS=-Xms512M -Xmx1024M -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Djava.rmi.server.hostname='192.168.1.173' -Dcom.sun.management.jmxremote.local.only=false
      - JAVA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname='192.168.1.173' -Dcom.sun.management.jmxremote.local.only=false
    depends_on:
      - configproperties
    expose:
      - "8085"
      - "1099"
    volumes:
      - app-volume:/tmp/cprocess:rw
volumes:
  app-volume:

当我的应用程序尝试连接到外部服务器时,出现此错误:

java.rmi.RemoteException: DSConnect.connect: (RemoteException)unable to connect to >DocuShare< >ops< in a timely mannor

有人可以帮助我通过RMI连接与我的服务器联系吗?

此致

0 个答案:

没有答案