I'm trying to use Keycloak quick starts in https://github.com/keycloak/keycloak-quickstarts.
I ran app-nodejs-html5 (https://github.com/keycloak/keycloak-quickstarts/tree/latest/app-nodejs-html5) , Keycloak 20.0.1 & service-nodejs (https://github.com/keycloak/keycloak-quickstarts/tree/latest/service-nodejs) all inside a docker-compose.
The front end app 'app-nodejs-html5' & key cloak server communication happen without an issue. But API service 'service-nodejs' & keycloak server communication not working properly. When I try to access API from frontend it every time return HTTP code 403.
When I move out service from docker-compose to outside all apps are working fine.
I suspect when both service & keycloak are in docker-compose, API service trying to access Keycloak using both http://localhost:3001 & http://keycloak.local:8080 URL's.
I tried using Frontend URL but that didn't work either.
I tried adding aliases & it didn't work too. ref : Keycloak and Spring Boot web app in dockerized environment
Did anyone succeed running keycloak & API service inside a docker compose ?
Extract from docker-compose
keycloak:
# keycloak admin console is available at http://localhost:3001/admin
image: keycloak:20.0.1
build:
context: .
dockerfile: Dockerfile.keycloak
container_name: keycloak
hostname: keycloak.local
ports:
- "3001:8080"
- "3002:8443"
environment:
KC_HOSTNAME: localhost
KC_HOSTNAME_STRICT: "false"
KC_DB: postgres
KC_DB_USERNAME: dba
KC_DB_PASSWORD: password
KC_DB_SCHEMA: public
KC_DB_URL: jdbc:postgresql://database.local:5432/
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: password
entrypoint: /opt/keycloak/bin/kc.sh start-dev
depends_on:
- database