Can't use Keycloak with docker compose

Hello!

I am sort of new to docker, i used it for almost 1 month and I have one issue:

Today i made a Docker-compose file with a front end service for my app and i tried to add keycloak to that front end. The issue is that i have the keycloak container service name “Keycloak” and when i check from my-app config that the keycloak container is okay ( http:/keycloak:< port number >/ or https://< ip of the keycloak container >: / ).

When i tried to access the http port of my app ( https:/localhost:< my-app port number > ) to redirect me to my login page i get redirected to https:/keycloak:< port number > instead of https:/localhost:< keycloak port number >.

My question is: is there any way that i can map the keycloak port or get the container IP address when i run docker-compose up from my docker file?

I found an work-around that allows me to access https:/keycloak:< port number > by modifying my /etc/hosts file, but it is not an very nice way to do that. Thanks in advance for any tips that can help me solve my problem.

hi…have you found out the solution?

I am facing this kind of problem in my environment. Please do let me know the solution or advice.

Best regards,
Khine