I am new to Keycloak, but I’m trying to set it up for a service I am creating. Below is a docker compose file for the (experimental) setup I am using. Some hostnames and passwords has been
modified
When starting the configuration , I am able to log into Keycloak and it seems to work
normally. However, there is no shred of evidence that the Postgres database is being used.
In PyCharm, the database is available, but as you can see, the “public” bit of it, where all the tables should have been, is empty.
I have tried all the combinations of configurations I could think of, but none of them seems to make any difference with respect to use of Postgres.
All helps will be very greatly appreciated.
Best wishes
Bjørn
Content of my docker-compose.yml file:
version: '3.8'
services:
postgres:
image: postgres:15.5-alpine3.19
volumes:
- ./postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
networks:
- backend
auth:
image: quay.io/keycloak/keycloak:23.0.3
ports:
- "8080:8080"
environment:
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=verysecretpwd
- KEYCLOAK_IMPORT=/tmp/realm.json
- KC_PROXY=edge
- KC_HOSTNAME=some-external-site.somewhere
- PROXY_ADDRESS_FORWARDING=true
- LOG_LEVEL=ALL
- KEYCLOAK_IMPORT=/opt/keycloak/data/import/realm.json
#Don't know how to connect to postgres database. NONE of these seems work:
- KC_HEALTH_ENABLED=true
- KC_METRICS_ENABLED=true
- KC_DATABASE=postgres
- KC_DB_VENDOR=POSTGRES
- KC_DB_ADDR=postgres
- KC_DB_DATABASE=keycloak
- KC_DB_USER=keycloak
- KC_DB_SCHEMA=public
- KC_DB_PASSWORD=password
- DATABASE=postgres
- DB_VENDOR=POSTGRES
- DB_ADDR=postgres
- DB_DATABASE=keycloak
- DB_USER=keycloak
- DB_SCHEMA=public
- DB_PASSWORD=password
depends_on:
- postgres
command:
- start
volumes:
- ./auth/import:/opt/keycloak/data/import
networks:
- backend
networks:
backend:
name: backend
driver: bridge
volumes:
postgres_data:
driver: local