DEV Community

Cover image for How to Set Up Quay.io/Keycloak with Docker Compose for Local Development?
Ram Kumar Bhandari
Ram Kumar Bhandari

Posted on

How to Set Up Quay.io/Keycloak with Docker Compose for Local Development?

Hey there! Are you looking for a powerful and easy-to-use Identity and Access Management (IAM) solution for your app? Look no further than Quay.io/Keycloak In this blog, I’ll show you how to set up and use Quay.io/Keycloak with docker-compose for local development.

version: '3.8'

services:
  keycloak_database:
    container_name: keycloak_database
    hostname: keycloak_database
    image: postgres:latest
    environment:
      POSTGRES_DB: keycloak
      POSTGRES_USER: keycloak
      POSTGRES_PASSWORD: keycloak
    ports:
      - 5432:5432
    volumes:
      - "./keycloak-dump.sql:/docker-entrypoint-initdb.d/keycloak-dump.sql:ro"

  keycloak:
    container_name: keycloak
    hostname: keycloak
    image: quay.io/keycloak/keycloak:latest
    environment:
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: admin
      KC_DB: postgres
      KC_DB_URL_HOST: keycloak_database
      KC_DB_URL_PORT: 5432
      KC_DB_URL_DATABASE: keycloak
      KC_DB_USERNAME: keycloak
      KC_DB_PASSWORD: keycloak
    command: start-dev
    ports:
      - 8080:8080
    depends_on:
      - keycloak_database

Enter fullscreen mode Exit fullscreen mode

docker-compose up will start a postgres container with prefilled data stored in keycloak-dump.sql file and you will be able to access keycloak instance in localhost:8080.

Just a heads up, there are already plenty of articles out there about implementing Keycloak in a web server. To keep things simple, I’ve decided not to include that part here. But if you’re interested in learning more, feel free to let me know in the comments! 😊

Helpful links

  1. Keycloak
  2. Keycloak-getting-started-docker

Top comments (0)