Reputation: 658
I am trying to run Keycloak 18 with postgres 10.21
Here is my docker compose
version: "3.5"
services:
keycloaksvc:
image: quay.io/keycloak/keycloak:18.0
user: '1000:1000'
container_name: "testkc"
environment:
- DB_VENDOR=postgres
- DB_ADDR=postgressvc
- DB_DATABASE=keycloak
- DB_PORT=5432
- DB_SCHEMA=public
- DB_USER=KcUser
- DB_PASSWORD=KcPass
- KC_HOSTNAME=localhost
- ROOT_LOGLEVEL=DEBUG
- PROXY_ADDRESS_FORWARDING=true
- REDIRECT_SOCKET=proxy-https
- KEYCLOAK_LOGLEVEL=DEBUG
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=testing
volumes:
- ./ssldir:/etc/x509/https
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
- "/etc/passwd:/etc/passwd:ro"
- ./kcthemes:/opt/keycloak/themes
entrypoint: /opt/keycloak/bin/kc.sh start --auto-build --hostname-strict-https=false --http-relative-path=/auth --features=token-exchange --https-certificate-file=/etc/x509/https/tls.crt --https-certificate-key-file=/etc/x509/https/tls.key
network_mode: "host"
depends_on:
- postgressvc
postgressvc:
image: postgres:10.21-alpine
user: '1000:1000'
container_name: "kc_postgres"
environment:
- POSTGRES_DB=keycloak
- POSTGRES_USER=KcUser
- POSTGRES_PASSWORD=KcPass
volumes:
- ./pgdta:/var/lib/postgresql/data
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
- "/etc/passwd:/etc/passwd:ro"
network_mode: "host"
It runs fine and I can get to admin console https://localhost:8443/auth/admin
I can also add new realm and users. However I do not see any data in postgres. If I make change in docker-compose file and restart, all the realms and users are lost
Exact same postgres setup works fine with image: jboss/keycloak:16.1.1
What setup am I missing for keycloak 18 ?
Upvotes: 3
Views: 5092
Reputation: 99
I am also facing the same issue with keycloak v19.0.0 . It was storing data in memory. But with below configuration able to store data in postgres.
keycloak:
container_name: keycloak
environment:
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://localhost:5432/keycloak
KC_DB_USERNAME: postgres
KC_DB_PASSWORD: user
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
KC_HOSTNAME_STRICT: false
KC_EDGE: proxy
ports:
- 8080:8080
image: quay.io/keycloak/keycloak:19.0.0
network_mode: host
depends_on:
- postgres
command:
- start-dev --auto-build
Upvotes: 6
Reputation: 28666
Keycloak from version 17 has major changes (it is based on the Quarkus) and also config has been changed. So don't use config, which is working with Keycoak 16, but check the current Keycloak doc, e.g. https://www.keycloak.org/server/containers
You will find that DB env variables are now:
KC_DB_URL,KC_DB_USERNAME,KC_DB_PASSWORD,...
Also other env variables have been changed, so it is not only about DB env variables.
Upvotes: 4