0
votes

I am new to docker . I am trying to access a spring boot service via Zuul url using docker containers. I have containerized the db, the spring boot service, eureka server and the Zuul gateway. Without dockerization, zuul is able to proxy the request to desired service using the host url.

P.S. Both the spring boot service and the zuul gateway are getting registered to the eureka server in docker. Below is the configuration of Zuul gateway:-

zuul.routes.vehicle.url=http://hostname:9010

I have also tried,

zuul.routes.vehicle.serviceId=vehicle (i.e. eureka serviceId)
zuul.routes.vehicle.stripPrefix=false

with:-

ribbon.eureka.enabled=true

Both doesnot work in my case. I can see the PreFilter and Postfilter of Zuul getting hit via logs, but the forwarding is not happening.

I brought up the Zuul service like this:

docker run -it -p 9001:9001 --name zuulservice --link vehicleservice -d zuulservice bash

I am trying to access the resource like this:

 http://localhost:9001/vehicle/resource

Am I missing something?? I am using Docker 17.12

1

1 Answers

0
votes

linking container is a legacy feature, avoid using it, create your own network card or use default network, doing

docker network ls 

gives you

NETWORK ID          NAME                DRIVER              SCOPE
634e05482aba        bridge              bridge              local
d2dfea98cab4        host                host                local
faf2f1516987        none                null                local

lets say we pick host network ,

deploy your container into host network directly, they will be able to talk to each other command would be

docker run -itd --network=host --name myZuulContainer <image name>

do this for all containers

thats it, let me know if it works,