代码改变世界

keycloak 配置DB

  qgbo  阅读(294)  评论(0编辑  收藏  举报

docker hub 上搜keycloak 镜像,下载最多的是  https://hub.docker.com/r/bitnami/keycloak

这个怎么设置都是 postgreSQL

In the office document, there is this words: The Bitnami Keycloak container requires a PostgreSQL database to work, this means PostgreSQL can be used if we want use the image!?

 this is details of the images https://github.com/bitnami/containers/tree/main/bitnami/keycloak

 

and a dockerFile exist!

yes, the image come form docker.io/bitnami/minideb:bullseye。In it , the keycloak package will be downloaded and put into the image.

when the container start up, the 2 scripts will execute:

ENTRYPOINT [ "/opt/bitnami/scripts/keycloak/entrypoint.sh" ]
 CMD [ "/opt/bitnami/scripts/keycloak/run.sh" ]  

in them, the kc.sh start ,which we can understand will execute.

So we should change image!

The image provided by office is keycloak/keycloak

So, first we shold create a new empty database, then create a user who can access the database.

execute the cmd,then it can start up;

 

kc.bat --verbose start-dev --db mssql --db-url "jdbc:sqlserver://<host>;databaseName=keycloak;user=q;password=1;encrypt=false" --transaction-xa-enabled=false --db-schema dbo

also like this:

复制代码
version: '3.8'

services:
  keycloak:
    image: keycloak/keycloak:20.0.3
    command: --verbose start-dev
    environment:
      - PROXY_ADDRESS_FORWARDING=true
      - KC_PROXY=passthrough
      - KC_HTTP_RELATIVE_PATH=keycloak
      - KC_DB=mssql
# user=q;password=q this 2 config can be overrided by the following config in env
- KC_DB_URL=jdbc:sqlserver://<host>;databaseName=keycloak;user=q;password=q;encrypt=false;trustServerCertificate=true; - KC_DB_HOST= - KC_DB_PORT=1433 - KC_DB_USERNAME=q - KC_DB_PASSWORD=q - KC_DB_SCHEMA=dbo - KC_TRANSACTION_XA_ENABLED=false networks: - app-net - middleware-net deploy: mode: replicated placement: constraints: - "node.hostname==keycloak" replicas: 1 labels: - "traefik.enable=true" - "traefik.docker.network=middleware-net" - "traefik.http.routers.keycloak.entrypoints=traefik" - "traefik.http.routers.keycloak.rule=PathPrefix(`/keycloak/`)" - "traefik.http.services.keycloak.loadbalancer.server.port=8080" networks: ****
复制代码

 

 

 this is a useful link: https://github.com/keycloak/keycloak-community/blob/main/design/keycloak.x/configuration.md

 

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· Qt个人项目总结 —— MySQL数据库查询与断言
点击右上角即可分享
微信分享提示