Trying to spin up keycloak 22 in local with mariadb as database

Hi,
I am working on upgrading keycloak 13 to 22. And so exported QA db and imported into my lcoal and trying to spin up keycloak. I am sure it same db I am using in my docker-compose.
I am trying to spin up keycloak using docker compose and my docker-compose is as below

version: '3'

networks:
  keycloak-local:
    ipam:
      driver: default
      config:
        - subnet: "172.16.123.0/24"
        - subnet: "2001:3984:3989::/64"

volumes:
  mariadb_data_keycloak:
    driver: local
  keycloak_data:
    driver: local

services:

  mariadb:
    image: mariadb:latest
    container_name: mariadb
    networks:
      - keycloak-local
    user: root
    ports:
      - 3306:3306
    environment:
      - BITNAMI_DEBUG=true
      - MARIADB_ROOT_PASSWORD=keycloak
      - MARIADB_DATABASE=keycloak
      - MARIADB_USER=keycloak
      - MARIADB_PASSWORD=keycloak
      - MARIADB_REPLICATION_MODE=master
      - MARIADB_REPLICATION_USER=keycloak
      - MARIADB_REPLICATION_PASSWORD=keycloak
    volumes:
      - ./db-init-scripts:/docker-entrypoint-initdb.d
      - ${PWD}/config/mariadb/my_custom.cnf:/opt/bitnami/mariadb/conf/bitnami/my_custom.cnf
      - 'mariadb_data_keycloak:/var/lib/mysql/data'

  keycloak-22:
    # slim doesn't include MySQL support, so switch to the larger image
    image: quay.io/keycloak/keycloak:22.0.4
    container_name: ff-keycloak-22
    depends_on:
      - mariadb
    links:
      - mariadb
    environment:
      - KEYCLOAK_ADMIN=admin
      - KEYCLOAK_ADMIN_PASSWORD=admin
      - KC_HOSTNAME_URL=http://localhost:8080
      - KC_HOSTNAME_ADMIN_URL=http://localhost:8080
      - DB_VENDOR=mariadb
      - DB_ADDR=mariadb
      - DB_PORT=3306
      - DB_DATABASE=keycloak
      - DB_USER=keycloak
      - DB_PASSWORD=keycloak
      - KEYCLOAK_LOGLEVEL= DEBUG
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:8080/health/ready" ]
      interval: 15s
      timeout: 2s
      retries: 15
    command: start --proxy edge
    ports:
      - 8080:8080
    networks:
      - keycloak-local
    volumes:
      - keycloak_data:/opt/jboss/keycloak/standalone/data

But when I start up, I am not seeing any data from db. ANd I am able create same realm and I dont see any changes in the DB when I make changes on UI. I am able to create the realm with the same name that is in DB.
How do I know what DB is it connecting ?
And what is wrong in above docker-compose as it is connecting to h2.

You are using a wild mixture of new and old environment variables.
Read the docs is always a good advice, it’s all in there!
See Configuring the database - Keycloak to find everything about database configuration and other guides for other configuration options.

1 Like

thanks @dasniko that helped

1 Like