Public | Automated Build

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

Keycloak HA PostgreSQL

Example Docker file for clustered Keycloak using a 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=password -d postgres

Start a Keycloak HA instance

Start two or more Keycloak instances that form a cluster and connect to the PostgreSQL instance running in previously started 'postgres' container:

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

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

Other details

This image extends the jboss/keycloak-postgres image. Please refer to the README.md for selected images for more info.

Docker Pull Command
Owner
jboss
Source Repository

Comments (5)
sphenrie
2 months ago

I was able to get a cluster running in openshift last week using the k8 ping functionality. This repo was very helpful.
https://github.com/fabric8-services/keycloak-deployment

arvinep
2 months ago

You need to do these changes for clustering to work for you:
https://github.com/jboss-dockerfiles/keycloak/pull/59/files

bechhansen
3 months ago

@mrpardijs You will also need to map all the jgroup used ports using -p wount you?

mrpardijs
6 months ago

JGroups is using the 'private' network interface, you have to bind this interface to an IP which is accessible from outside the container using the -bprivate configuration option. See https://github.com/jboss-dockerfiles/keycloak/pull/59 for more details

dbetancourt
7 months ago

According to this blog:

http://blog.keycloak.org/2015/04/running-keycloak-cluster-with-docker.html

If you find in the logs the phrase:

Received new cluster view: [b5356f1050cc/keycloak|1] (2) [b5356f1050cc/keycloak, f25f922ce14d/keycloak]

Then your nodes are in cluster mode.

I have followed the instructions on this page, but the outcome is always:

Received new cluster view for channel ejb: [9d21bc8778f0|0] (1) [9d21bc8778f0]
Received new cluster view for channel hibernate: [9d21bc8778f0|0] (1) [9d21bc8778f0]
Received new cluster view for channel keycloak: [9d21bc8778f0|0] (1) [9d21bc8778f0]
Received new cluster view for channel web: [9d21bc8778f0|0] (1) [9d21bc8778f0]
Received new cluster view for channel server: [9d21bc8778f0|0] (1) [9d21bc8778f0]

Only takes one node :(

I used version 2.5.1.Final

Any idea?