samibe
samibe

Reputation: 1

Running multiple docker-compose on multiple servers to run keycloak instances and share cache using JDBC-PING

anybody know how to share the cache between hosts that runs the same docker-compose:

version: '3'
services:
  keycloak-clustered-3:
    build: ./keycloak
    container_name: keycloak-clustered-3
    command: start-dev
    ports:
      - "8080:8080"
    environment:
      - KEYCLOAK_ADMIN=admin
      - KEYCLOAK_ADMIN_PASSWORD=admin
      - KC_DB=mysql
      - KC_DB_URL_HOST=dbhost
      - KC_DB_URL_DATABASE=keycloak
      - KC_DB_USERNAME=keycloak
      - KC_DB_PASSWORD=password
      - KC_LOG_LEVEL=INFO,org.infinispan:DEBUG,org.jgroups:DEBUG
      - JGROUPS_DISCOVERY_EXTERNAL_IP=keycloak-clustered-3
      - KC_PROXY=edge
      - JGROUPS_DISCOVERY_PROTOCOL=JDBC_PING

    networks:
      - keycloak-net

  keycloak-clustered-4:
    build: ./keycloak
    container_name: keycloak-clustered-4
    command: start-dev
    ports:
      - "8081:8080"
    environment:
      - KC_PROXY=edge
      - KEYCLOAK_ADMIN=admin
      - KEYCLOAK_ADMIN_PASSWORD=admin
      - KC_DB=mysql
      - KC_DB_URL_HOST=dbhost
      - KC_DB_URL_DATABASE=keycloak
      - KC_DB_USERNAME=keycloak
      - KC_DB_PASSWORD=password
      - KC_LOG_LEVEL=INFO,org.infinispan:DEBUG,org.jgroups:DEBUG
      - JGROUPS_DISCOVERY_EXTERNAL_IP=keycloak-clustered-4
      - JGROUPS_DISCOVERY_PROTOCOL=JDBC_PING

    networks:
      - keycloak-net
  nginx:
    image:  nginx:1.23.4
    restart: unless-stopped
    container_name: nginx
    ports:
      - "80:80"
    depends_on:
      - keycloak-clustered-3
      - keycloak-clustered-4
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    networks:
      - keycloak-net
networks:
  keycloak-net:

i have this config:

the cache is shared only on the instances running on the same server, so if you have a solution for this it will be so helpful for me.

Upvotes: 0

Views: 390

Answers (1)

A. Sa.
A. Sa.

Reputation: 431

You start your keycloak services with start-dev which by default uses the local caches:

When you start Keycloak in development mode, by using the start-dev command, Keycloak uses only local caches and distributed caches are completely disabled by implicitly setting the --cache=local option. The local cache mode is intended only for development and testing purposes.

see: https://www.keycloak.org/server/caching

Upvotes: 0

Related Questions