Hi , i deployed API gate way KONG and a simple spring boot micro service on my docker instance(MAC docker installation)
i exposed port of spring boot application and i can access it from my host machine(via browser)
However when i try via KONG instance, it gives 502 error
below is the command to install kong
docker run -d --name kong-database \
--network=kong-net \
-p 9042:9042 \
cassandra:3
docker run --rm \
--network=kong-net \
-e "KONG_DATABASE=cassandra" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
kong:latest kong migrations bootstrap
docker run -d --name kong \
--network=kong-net \
-e "KONG_DATABASE=cassandra" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
kong:latest
used below commands for building posting micro service on kong
Dockerfile
FROM openjdk:12
ADD target/userservice.jar userservice.jar
EXPOSE 9090
ENTRYPOINT [“java”,"-jar",“userservice.jar”]
docker build -f Dockerfile -t userservice .
docker run -p 9090:9090 --network=kong-net --hostname=userservice userservice
i logged in to userservice container and identified the IP
“Gateway”: “172.17.0.1”,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”
when i logged in to kong container and curl its refusing connection
/ # curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://172.18.0.2:9090/userservice
curl: (7) Failed to connect to 172.18.0.2 port 9090: Connection refused
i wonder how i can access microservice from out side of docker world(http://localhost:9090/userservice/)
and unable to access from the other container of the same docker.
i goal is to reach the microservice via gateway(kong here). i added necessary services and routes to kong and found 502 issue(upstream url not found), then i am trying to accessing the services with in docker containers as explained above
any thing i miss here?
-Rana