Public | Automated Build

Last pushed: 12 days ago
Short Description
Short description is empty for this repo.
Full Description

Keycloak PostgreSQL

Extends the Keycloak docker image to use PostgreSQL

Usage

Start a PostgreSQL instance

First start a PostgreSQL instance using the PostgreSQL docker image:

docker run --name postgres -e POSTGRES_DATABASE=keycloak -e POSTGRES_USER=keycloak -e POSTGRES_PASSWORD=password -e POSTGRES_ROOT_PASSWORD=root_password -d postgres

Start a Keycloak instance

Start a Keycloak instance and connect to the PostgreSQL instance:

docker run --name keycloak --link postgres:postgres jboss/keycloak-postgres

Environment variables

When starting the Keycloak instance you can pass a number of environment variables to configure how it connects to PostgreSQL. For example:

docker run --name keycloak --link postgres:postgres -e POSTGRES_DATABASE=keycloak -e POSTGRES_USER=keycloak -e POSTGRES_PASSWORD=password jboss/keycloak-postgres

POSTGRES_DATABASE

Specify name of PostgreSQL database (optional, default is keycloak).

POSTGRES_USER

Specify user for PostgreSQL database (optional, default is keycloak).

POSTGRES_PASSWORD

Specify password for PostgreSQL database (optional, default is password).

Docker Pull Command
Owner
jboss
Source Repository

Comments (10)
muzaparoff
4 days ago

Guys can someone help me to find solution to create backup/restore problem? Here I posted in stackoverflow question: https://stackoverflow.com/questions/46281416/best-practices-of-export-import-keycloak-data-in-kubernetes

Thanks

michaelchristensen
17 days ago

Just tried starting this image with -e KEYCLOAK_LOGLEVEL=DEBUG. However, I still only get INFO and WARN level logs. I thought the loglevel env. setting would work on this image since it is based on https://hub.docker.com/r/jboss/keycloak/. Any ideas?

jimbali
18 days ago

Current 'latest' tag seems to be broken (2017-09-06T15:13:35Z)

The container throws loads of JDBC driver errors when trying to connect to a DB.

3.2.1.Final and 3.3.0CR1 work fine.

cchet
7 months ago

Update doc regarding starting postgres container because the alternative name for the default database is not defined via the parameter "POSTGRES_DATABASE" but via 'POSTGRES_DB'

tirithen
a year ago

How can I configure realm, realm key and credentials secret with environment variables in my docker-compose.yml file so I can reference these in my other services?

benzht
a year ago

Some important information still missing from the description above (and faulty in a comment below)

To create an admin user with environment variables, add

-e KEYCLOAK_USER=<USERNAME> -e KEYCLOAK_PASSWORD=<PASSWORD>

to the run command.

To add them later, call

docker exec keycloak keycloak/bin/add-user-keycloak.sh --user <USERNAME> --password <PASSWORD>
trajakovic
a year ago

@vaughnmb

yeah, they still use "legacy" linking env.

for v2 docker-compose, just link your postgres as you would normally do, ie.:

  • keycloak-postgresql:postgres

and then add env

environment:

POSTGRES_PORT_5432_TCP_ADDR=postgres
POSTGRES_PORT_5432_TCP_PORT=5432

vaughnmb
a year ago

This image doesn't seem to work with docker-compose version 2. It looks like it still uses Environment Variables when setting up Keycloak Datasource in wildfly.

jacksonemmerich
a year ago

Add user admin for jboss and keycloak:
docker exec <CONTAINER> keycloak/bin/add-user.sh -u <USERNAME> -p <PASSWORD>

rajatnair
2 years ago

Looks like a typo - Dockerfile is loading Keycloak version 1.2.0.Final. Can someone fix this to 1.4.0.Final?