You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using KeyCloak via Docker with an external PostgreSQL database
#14029
Hey Naushadh,
thank you very much for your answer.
I tried this, but unfortunately it failed because the parameter "-e ...." (as an example) is not known by the programme.
The description on the page: "https://hub.docker.com/r/jboss/keycloak/" therefore does not quite match the programme.
Do you have any idea how I can set this? Should I leave out the "-e ..." everywhere?
I tried that too with all the possible parameters listed there. But unfortunately the JDBC cannot establish the connection. I also do not have a "URL" for the DB server where this programme can dock. I assume that this can only work if I set up a PostgreSQL instance directly on the DOCKER as described there.
However, I would like to address an external DB instance that is NOT on this host.
Hey,
well..... I tried it in this way:
docker run --name -p 8080:8080 -e KEYCLOAK_ADMIN= -e KEYCLOAK_ADMIN_PASSWORD= jboss/keycloak DB_VENDOR=postgres POSTGRES_PORT= POSTGRES_DATABASE= POSTGRES_USER= POSTGRES_PASSWORD=
The Different between your and my command-line is, that you write the name of image after all parameters and I between the parameters. I would like to try it and give you a feedback.
Hey,
I tried it now and I´ve got this Error - Message:
FATAL [org.keycloak.services] (ServerService Thread Pool -- 57) Error during startup: java.lang.RuntimeException: Failed to connect to database
Which version of PostgreSQL is supported in this software & should I use the IP address rather than the hostname?
Best Regards
I'm also looking for a way to setup the (logical) PostgreSQL database for a docker compose setup. I have the PostgreSQL container running, but no nice way to configure the initial database creation anywhere.
This discussion was converted from issue #13845 on August 26, 2022 09:43.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Description
Hello all,
I am struggling to create a Dockerfile for KeyCloak that will allow me to use my external database server and its port.
Does anyone here have any ideas, suggestions on how I can do this?
Or would it make more sense for me to build an image that only accepts requests for Postgres and then pass them on?
Or who has another idea?
The point is that I have a central database server and I can monitor, maintain and back it up.
best regards from Berlin
Z. Matthias
All reactions
Replies: 8 comments · 1 reply
Uh oh!
There was an error while loading. Please reload this page.
You can use the official Keycloak docker image jboss/keycloak, which supports configuring the PostgreSQL database (see environment variables section).
All reactions
Uh oh!
There was an error while loading. Please reload this page.
You have read this section of the documentation, haven't you?
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Hey Naushadh,
thank you very much for your answer.
I tried this, but unfortunately it failed because the parameter "-e ...." (as an example) is not known by the programme.
The description on the page: "https://hub.docker.com/r/jboss/keycloak/" therefore does not quite match the programme.
Do you have any idea how I can set this? Should I leave out the "-e ..." everywhere?
Best regards from Berlin
Z. Matthias
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Hey Alexted,
Thank you very much for your answer.
I tried that too with all the possible parameters listed there. But unfortunately the JDBC cannot establish the connection. I also do not have a "URL" for the DB server where this programme can dock. I assume that this can only work if I set up a PostgreSQL instance directly on the DOCKER as described there.
However, I would like to address an external DB instance that is NOT on this host.
Do you have another idea?
Kind regards
Z. Matthias
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Can you share what command(s) you've tried and what the output(s) were?
This should just work (replacing the
<PLACEHOLDERS>with your own database's credentials)$ docker run \ -e KEYCLOAK_USER=<USERNAME> \ -e KEYCLOAK_PASSWORD=<PASSWORD> \ -e DB_VENDOR=postgres \ -e DB_ADDR=<HOST NAME> \ -e DB_PORT=<PORT NUM> \ -e DB_USER=<DB USERNAME> \ -e DB_PASSWORD=<DB PASSWORD> \ -p 8080:8080 jboss/keycloakAll reactions
Uh oh!
There was an error while loading. Please reload this page.
Hey,
well..... I tried it in this way:
docker run --name -p 8080:8080 -e KEYCLOAK_ADMIN= -e KEYCLOAK_ADMIN_PASSWORD= jboss/keycloak DB_VENDOR=postgres POSTGRES_PORT= POSTGRES_DATABASE= POSTGRES_USER= POSTGRES_PASSWORD=
The Different between your and my command-line is, that you write the name of image after all parameters and I between the parameters. I would like to try it and give you a feedback.
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Hey,
I tried it now and I´ve got this Error - Message:
FATAL [org.keycloak.services] (ServerService Thread Pool -- 57) Error during startup: java.lang.RuntimeException: Failed to connect to database
Which version of PostgreSQL is supported in this software & should I use the IP address rather than the hostname?
Best Regards
Z. Matthias
All reactions
Uh oh!
There was an error while loading. Please reload this page.
I'm also looking for a way to setup the (logical) PostgreSQL database for a docker compose setup. I have the PostgreSQL container running, but no nice way to configure the initial database creation anywhere.
All reactions
Uh oh!
There was an error while loading. Please reload this page.
See the quickstart setup of postgres - https://raw.githubuserc 8000 ontent.com/keycloak/keycloak-quickstarts/refs/heads/main/kubernetes/keycloak.yaml the pg container takes a POSTGRES_DB environment variable.
All reactions