0
votes

I´ve been trying to validade my microservices on a Docker structure, where i connect everything through linking containers but i´m not having success when trying to pass through an API Gateway with Zuul.

Basically i have theses microservices:

  • config-server
  • boutique-eureka-server
  • api-gateway
  • product-service

All of these start with success but i can´t acess the product-service behing the api-gateway.

My code is all at:

https://github.com/kalilmvp/myboutique/

along with the docker commands that i´ve used.

The error usually is:

com.netflix.zuul.exception.ZuulException: Forwarding error

In my later tests i´ve been also having this error:

Caused by: java.lang.RuntimeException: java.net.UnknownHostException: product-service

You can check it on the branch docker

1
But micro services without docker are well registered on the eureka server? Because by checking your client configuration I don't see you giving them the address of the eureka server.Francesc Recio
Hi @FrancescRecio, yes they are. This problem is only happening when using Docker. Where would i put the address? Because i did configure like this on application.yml, which is inherited by all the other configurations: eureka: client: serviceUrl: defaultZone: ${SERVICE_URL_DEFAULT_ZONE}Kalil Peixoto

1 Answers

0
votes

Docker advises not to use --link option to link the containers and therefore this switch of docker run is deprecated.

There are many problems creating end-to-end links, like for example environment variables are being shared between 2 linked containers (imagine different values of JAVA_HOME for example).

Instead try coordinating your services using docker compose or define network using docker:

$ docker network create my-net
$ docker create --name my-eureka --network my-net --publish 8888:80 eureka:latest
...
$ docker network disconnect my-net my-eureka

Find more info in the docker docs