With Docker

Running Keycloak with Docker. The official image is not in Docker Images website, but in this one bellow:

Keycloak Docker Image
Guides for integrations

Check more options running with containers here.

Initial configuration of Keycloak.

By default, the server is listening for http and https requests using the ports 8080 and 8443, respectively.

The Dabase used is not created/maintained by Keycloak, it must be created and informed to Keycloack.

Simple Dev Container

With a Docker Compose configuration:

compose.yaml
services:
  keycloack:
    image: quay.io/keycloak/keycloak:latest
    command: start-dev
    ports:
      - 8080:8080
    environment:
      - KC_BOOTSTRAP_ADMIN_USERNAME=admin
      - KC_BOOTSTRAP_ADMIN_PASSWORD=admin
compose.yaml
services:
  keycloak-postgres:
    image: postgres
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: keycloak
      POSTGRES_USER: keycloak
      POSTGRES_PASSWORD: password
      
  keycloak:
    image: quay.io/keycloak/keycloak:latest
    environment:
      DB_VENDOR: POSTGRES
      DB_ADDR: keycloak-postgres
      DB_DATABASE: keycloak
      DB_USER: keycloak
      DB_SCHEMA: public
      DB_PASSWORD: password
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: password
    ports:
      - "8080:8080"
    depends_on:
      - keycloak-postgres

Optimized Production Container

By default, when you use the start or start-dev command, Keycloak runs a build command under the covers for convenience reasons.

Check the Guides for more info on configuring for production environments.

Last updated