0
votes

I've following services and working fine when they are deployed in localhost (through eclipse). But unable to invoke the rest service when deployed as separate docker containers.

I'm new docker and attended the tutorials to have knowledge on how this works.

Following services are running in separate docker containers and configured as follows (local environment)

Eureka

Docker IP : 172.17.0.3
Docker port mapping : 8761:8761

spring.application.name=naming-server
server.port=8761

Zuul API gate way

Docker IP : 172.17.0.4
Docker port mapping : 8765:8765

spring.application.name=gateway-server
server.port=8765

User service

Docker IP : 172.17.0.5
Docker port mapping : 8101:8101

spring.application.name=user-service
server.port=8101

Registered services info in Eureka

Application AMIs Availability Zones Status

USER-SERVICE n/a (1) (1) UP (1) - de4396a354ea:user-service:8101

API-GATEWAY n/a (1) (1) UP (1) - e5dd509065cd:api-gateway:8765

When tried to invoke the service in "User service" through gateway, it's throwing exception

    com.netflix.zuul.exception.ZuulException: Forwarding error
        at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.handleException(RibbonRoutingFilter.java:198) ~[spring-cloud-netflix-zuul-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]
        at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:173) ~[spring-cloud-netflix-zuul-2.2.0.RELEASE.jar!/:2.2.0.RELEASE]

    Caused by: java.net.UnknownHostException: de4396a354ea: Name or service not known
        at java.base/java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method) ~[na:na]
        at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929) ~[na:na]
        at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1515) ~[na:na]

Note: "de4396a354ea" is the container id for "User service"

Please guide on how to resolve this issue and also provide any links where I can get more info regarding deploying microservices in docker containers.

1

1 Answers

0
votes

Able to resolve this by adding "eureka.instance.hostname=" property.