no

How to run Keycloak with MySQL Database as Docker Containers

I. Introduction In this blog, we will create a docker-compose file that will run a Keycloak and MySQL instance as a docker container. Keyclo...

I. Introduction

In this blog, we will create a docker-compose file that will run a Keycloak and MySQL instance as a docker container. Keycloak will connect to the MySQL database using JDBC.

II. Prerequisites

Docker must be running on your local machine.

III. What should be inside the project?

  • The docker compose file
  • keycloak/import-realm.json - This realm will imported into Keycloak once a new instance is created. This file is use in the exercise available at https://github.com/czetsuya/keycloak-angular-auth/blob/master/config/keycloak-auth-realm.json.

IV. The Docker Compose File

version: "3"

networks: 
  backend:
  frontend:

services:
  keycloak:
    image: jboss/keycloak:10.0.2
    environment: 
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: kerri
      DB_ADDR: mysql
      DB_USER: keycloak
      DB_PASSWORD: keycloak
      DB_PORT: "3306"
      DB_DATABASE: keycloak
      KEYCLOAK_IMPORT: /tmp/import-realm.json
    ports: 
      - 8080:8080
    volumes: 
      - ./keycloak:/tmp
    networks: 
      - backend
      - frontend
  mysql:
    image: mysql:8.0.20
    environment: 
       MYSQL_ROOT_PASSWORD: kerri
       MYSQL_USER: keycloak 
       MYSQL_PASSWORD: keycloak
       MYSQL_DATABASE: keycloak
    ports: 
      - 3306:3306
    networks:
      - backend
  adminer:
    image: adminer
    restart: always
    ports:
      - 8081:8080
    networks: 
      - backend
      - frontend
      
Download the project at https://github.com/czetsuya/docker-keycloak-mysql.

Related

database 5249056117875196902

Post a Comment Default Comments

item