keycloak +docker-compose+mysql 启动配置
前言:最近通过jhipster框架了解到Keycloak,然后通过docker-compose+mysql在自己本地部署keycloak完成。
参考网址:
https://github.com/keycloak/keycloak-containers/blob/master/server/README.md —— jboss/keycloak镜像配置参数讲解
配置:
version: '2' services: mysql: image: mysql:5.7 volumes: - ./mysql_data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_DATABASE=keycloak - MYSQL_USER=keycloak - MYSQL_PASSWORD=123456 ports: - 3306:3306 networks: keycloak-network: keycloak: image: jboss/keycloak:10.0.0 command: [ '-b', '0.0.0.0', '-Dkeycloak.migration.action=import', '-Dkeycloak.migration.provider=dir', '-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config', '-Dkeycloak.migration.strategy=OVERWRITE_EXISTING', '-Djboss.socket.binding.port-offset=1000', '-Dkeycloak.profile.feature.upload_scripts=enabled', ] volumes: - ./realm-config:/opt/jboss/keycloak/realm-config networks: keycloak-network: environment: - KEYCLOAK_USER=admin - KEYCLOAK_PASSWORD=admin - DB_VENDOR=MYSQL - DB_ADDR=mysql - DB_DATABASE=keycloak - DB_USER=keycloak - DB_PASSWORD=123456 ports: - 9080:9080 - 9443:9443 - 10990:10990 depends_on: - mysql networks: keycloak-network:
部署步骤:
我使用的Centos7,首先要去下载Docker-compos(注意要先下载docker),然后参考以下步骤安装。
1、sudo curl -L "https://github.com/docker/compose/releases/download/1.28.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 2、sudo chmod +x /usr/local/bin/docker-compose 3、docker-compose --version
新建文件 keycloak.yml,把上面内容拷贝keycloak.yml文件中执行docker-compose -f keycloak.yml up 或者 docker-compose -f keycloak.yml up -d
访问 ip:9080出现如下界面就代表成功了