Docker Eureka UnknownHostException

时间:2017-06-13 10:07:12

标签: docker spring-boot netflix-eureka hystrix

我正在尝试使用dockerized springboot应用程序进行微服务架构。

对于内部通信,我想使用Eureka + FeignClient。 Eureka的注册工作正常(afaik):

    <application>
    <name>CAREER-SERVICE</name>
    <instance>
        <instanceId>4b62546fdc9b:career-service:7000</instanceId>
        <hostName>172.18.0.15</hostName>
        <app>CAREER-SERVICE</app>
        <ipAddr>172.18.0.15</ipAddr>
        <status>UP</status>
        <overriddenstatus>UNKNOWN</overriddenstatus>
        <port enabled="true">7000</port>
        <securePort enabled="false">443</securePort>
        <countryId>1</countryId>
        <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
            <name>MyOwn</name>
        </dataCenterInfo>
        <leaseInfo>
            <renewalIntervalInSecs>30</renewalIntervalInSecs>
            <durationInSecs>90</durationInSecs>
            <registrationTimestamp>1497345551521</registrationTimestamp>
            <lastRenewalTimestamp>1497347501260</lastRenewalTimestamp>
            <evictionTimestamp>0</evictionTimestamp>
            <serviceUpTimestamp>1497345550971</serviceUpTimestamp>
        </leaseInfo>
        <metadata class="java.util.Collections$EmptyMap"/>
        <homePageUrl>http://172.18.0.15:7000/</homePageUrl>
        <statusPageUrl>http://172.18.0.15:7000/info</statusPageUrl>
        <healthCheckUrl>http://172.18.0.15:7000/health</healthCheckUrl>
        <vipAddress>career-service</vipAddress>
        <secureVipAddress>career-service</secureVipAddress>
        <isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
        <lastUpdatedTimestamp>1497345551521</lastUpdatedTimestamp>
        <lastDirtyTimestamp>1497345550555</lastDirtyTimestamp>
        <actionType>ADDED</actionType>
    </instance>
</application>
<application>
    <name>AUTH-SERVICE</name>
    <instance>
        <instanceId>5ecc30b0fcd1:auth-service:5000</instanceId>
        <hostName>172.18.0.11</hostName>
        <app>AUTH-SERVICE</app>
        <ipAddr>172.18.0.11</ipAddr>
        <status>UP</status>
        <overriddenstatus>UNKNOWN</overriddenstatus>
        <port enabled="true">5000</port>
        <securePort enabled="false">443</securePort>
        <countryId>1</countryId>
        <dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
            <name>MyOwn</name>
        </dataCenterInfo>
        <leaseInfo>
            <renewalIntervalInSecs>30</renewalIntervalInSecs>
            <durationInSecs>90</durationInSecs>
            <registrationTimestamp>1497345537851</registrationTimestamp>
            <lastRenewalTimestamp>1497347517943</lastRenewalTimestamp>
            <evictionTimestamp>0</evictionTimestamp>
            <serviceUpTimestamp>1497345536974</serviceUpTimestamp>
        </leaseInfo>
        <metadata class="java.util.Collections$EmptyMap"/>
        <homePageUrl>http://172.18.0.11:5000/</homePageUrl>
        <statusPageUrl>http://172.18.0.11:5000/info</statusPageUrl>
        <healthCheckUrl>http://172.18.0.11:5000/health</healthCheckUrl>
        <vipAddress>auth-service</vipAddress>
        <secureVipAddress>auth-service</secureVipAddress>
        <isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
        <lastUpdatedTimestamp>1497345537851</lastUpdatedTimestamp>
        <lastDirtyTimestamp>1497345506847</lastDirtyTimestamp>
        <actionType>ADDED</actionType>
    </instance>
</application>

在我的一项服务中,我需要访问auth-service并尝试使用接口AuthServiceClient和@FeignClient Annotation进行:

FeignClient(name = "auth-service")
public interface AuthServiceClient {

  @RequestMapping(method = RequestMethod.POST, value = "/users", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
  void createUser(User user);
}

当我调用Method时,我得到以下异常:

account_1               | 2017-06-13 09:55:35.654 ERROR 1 --- [nio-6000-exec-6] o.a.c.c.C.[.[.[.[dispatcherServlet]      : Servlet.service() for servlet [dispatcherServlet] in context with path [/accounts] threw exception [Request processing failed; nested exception is com.netflix.hystrix.exception.HystrixRuntimeException: createUser failed and no fallback available.] with root cause
account_1               |
account_1               | java.net.UnknownHostException: auth-service

注册的IP是正确的我只是想知道他为什么不知道'auth-service'。所以我猜他甚至可能都没想和Eureka说话?我该如何调试?

0 个答案:

没有答案