无法通过IDE连接到docker上的jhipster spring注册表

时间:2016-07-21 13:41:05

标签: java spring-boot spring-cloud jhipster spring-cloud-config

我在Docker容器中运行JHipster注册表。 所有在docker上运行的应用程序都可以在注册表端点(端口8761)中进行连接和注册。

但是当我尝试连接在我的IDEA上运行的应用程序时,我在尝试连接到注册表端点时收到错误:

UnknownHostException: registry

应用程序连接到Register(在日志中查看),但之后我收到错误:

eureka:
    instance:
        prefer-ip-address: true
    client:
        enabled: true
        healthcheck:
            enabled: true
        registerWithEureka: true
        fetchRegistry: true
        serviceUrl:
            defaultZone: http://admin:admin@localhost:8761/eureka/

有没有人知道如何连接到在docker中运行的注册表?

我的spring application.yml是:

eureka:
    client:
        serviceUrl:
            defaultZone: http://admin:admin@localhost:8761/eureka/

jhipster-registry中的默认区域为http://user:pass@register:8761/eureka

如果我更改为localhost,请执行以下操作:

{{1}}

它可以工作,但在这种情况下,在docker中运行的服务无法访问注册表(反向问题)。

谢谢!

2 个答案:

答案 0 :(得分:2)

我有类似的问题。在3.5.0中,我能够成功启动基于docker的注册表,然后启动微服务和网关的非docker版本。使用3.5.1,我不再能够做到这一点,得到同样的错误。我认为这与https://github.com/jhipster/generator-jhipster/pull/3848有关。在任何情况下,我只是在我的/ etc / hosts文件中添加了一个条目,将“registry”指向127.0.0.1,并且它有效。

答案 1 :(得分:0)

运行微服务的docker上的localhost与运行注册表的docker上的localhost不同。我将localhost更改为主机的Intranet地址,这对我来说很有用。

eureka:
    instance:
        prefer-ip-address: true
    client:
        service-url:
            defaultZone: http://admin:${jhipster.registry.password}@10.31.224.228:8761/eureka/
相关问题