0

I have 2 microservices (spring boot app) running in different docker containers and configured with zuul api gateway. Routing to other container is not working. Container 1 is running in 8030 port & container 2 is running on port 8030.

Below is the zuul configuration in application.yml -

server:
  port: 8030

# TODO: figure out why I need this here and in bootstrap.yml

spring:
  application:
    name: zuul server

endpoints:
  restart:
    enabled: true
  shutdown:
    enabled: true
  health:
    sensitive: false

zuul:
  routes:
    zuultest:
         url: http://localhost:8080
         stripPrefix: false 

ribbon:
  eureka:
    enabled: false

When access through localhost:8030/zuultest/test am getting the exception as -

2016-09-19 09:10:14.597  INFO 1 --- [nio-8030-exec-3] hello.SimpleFilter                       : GET request to http://localhost:8030/zuultest/test
2016-09-19 09:10:14.600  WARN 1 --- [nio-8030-exec-3] o.s.c.n.z.filters.post.SendErrorFilter   : Error during filtering

Can I know why I am getting this?

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
sham raj
  • 11
  • 5

2 Answers2

2

you can use links option in the docker-compose.yml to link between the two containers.

demo1:
  image: <demo1 image name>
  links: - demo2
demo2:
  image: <demo2 image name>

Then in the zuul:routs:url configuration you can use the conatiner name, demo2 instead of it's IP.

Yuval Simhon
  • 1,439
  • 2
  • 19
  • 34
0

How did you start the 2 containers? Both cannot have the same port if you exposed them to the docker host.

docker run --name service A --net=host -p 8030:8030 ...
docker run --name service B --net=host -p 8030:8031 ...

Without this, if you are calling localhost:8030, you are calling the host (not the container), and you are not getting a response.

You need to map the port to the host when you start them with different ports, and call them with localhost to the right exposed port

Ali Dufour
  • 97
  • 2
  • 9