I am running docker desktop (windows) and building docker image for keycloak 17.0.0 following the instructions at here. Build completes successfully but when I run this image in desktop I get error
ERROR [org.key.qua.run.cli.ExecutionExceptionHandler] (main) ERROR: Failed to obtain JDBC connection
ERROR [org.key.qua.run.cli.ExecutionExceptionHandler] (main) ERROR: No suitable driver found for jdbc:postgresql://postgres/keycloak
postgres is already running in docker desktop with the name "postgres" on default port 5432 and has keyclock database created.
Here is my Dockerfile:
FROM quay.io/keycloak/keycloak-x:latest as builder
ENV KC_METRICS_ENABLED=true
ENV KC_FEATURES=token-exchange
ENV KC_DB=postgres
RUN /opt/keycloak/bin/kc.sh build
FROM quay.io/keycloak/keycloak-x:latest
COPY --from=builder /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/
WORKDIR /opt/keycloak
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
ENV KEYCLOAK_ADMIN=admin
ENV KEYCLOAK_ADMIN_PASSWORD=admin
ENV KC_DB_URL='jdbc:postgresql://postgres/keycloak'
ENV KC_DB_USERNAME=postgres
ENV KC_DB_PASSWORD=postgres
ENV KC_HOSTNAME=localhost:8443
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start"]
My understanding from the docs is, after setting "KC_DB=postgres", the build should have included postgres driver that appears to be missing.
Can somebody tell me what is wrong here? Thanks.