Keycloak-X runtime database configuration.

775 views
Skip to first unread message

Andrej Petras

unread,
Mar 11, 2021, 10:52:32 AM3/11/21
to Keycloak User
Hi,

I have a Keycloak-X Docker image that uses the PostgreSQL database.

I want to deploy the same Docker image in different namespaces with different database configuration (url, user, password).
How can i do it?

Thanks,
Andrej

Andrej Petras

unread,
Mar 12, 2021, 3:06:43 AM3/12/21
to Keycloak User
Do I need to use the --auto-config flag on production environment to configure the db password?

--
You received this message because you are subscribed to a topic in the Google Groups "Keycloak User" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/keycloak-user/LziqX5wprv0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to keycloak-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-user/8b6a58bd-0428-4cc7-aea8-5c7c52efef9bn%40googlegroups.com.

Meissa M'baye Sakho

unread,
Mar 12, 2021, 3:45:51 AM3/12/21
to Andrej Petras, Keycloak User
You don't. All you have to do is pass the url, user, password information as environment variables to your docker image.
But before being able to do that, you will need to have the db driver auto-configured. Because it's a runtime property and default to H2 database. 
1) Extends the docker image by specifying the database driver (something like the following):
FROM quay.io/keycloak/keycloak-x
WORKDIR /opt/jboss/keycloak
RUN ./bin/kc.sh config --db=postgres --http-enabled=true

2) And I can create the container with the following arguments assuming that you've built the container with the tag keycloak-x:1.1:
docker run -d --name keycloak -p 8080:8080 -p 8443:8443  \
    -e KEYCLOAK_ADMIN=xxxx \
    -e KEYCLOAK_ADMIN_PASSWORD=xxxx \
    -e KC_DB_URL=jdbc:postgresql://172.17.0.2:5432/keycloak \
    -e KC_DB_USERNAME=keycloak \
    -e KC_DB_PASSWORD=keycloak \
    keycloak-x:1.1

-
Meissa SakhoRHCA

Senior Architect

Red Hat EMEA

msa...@redhat.com   
M: +33-6-9559-7778    




You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-user/CADJMSyx%2BOJHYc-%3DWkkwNsT6Bc4D8hTmd0opE5ywWTVpq1mneBg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages