This guide runs Keycloak in a container using the official image.
See Docker installation: Docker
# Run Keycloak with latest stable version (26.5.4)
docker run -p 8080:8080 quay.io/keycloak/keycloak:26.5.4 start-dev
# Access the admin console at http://localhost:8080
# Default admin user will be auto-created with credentials shown in logs
Create a docker-compose.yml file:
version: '3.8'
services:
postgres:
image: postgres:16-alpine
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: change-me-db-password
healthcheck:
test: ["CMD-SHELL", "pg_isready -U keycloak"]
interval: 10s
timeout: 5s
retries: 5
keycloak:
image: quay.io/keycloak/keycloak:26.5.4
command: start
environment:
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres:5432/keycloak
KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: change-me-db-password
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: change-me-admin-password
KC_PROXY: reverse
KC_HTTP_RELATIVE_PATH: /auth
ports:
- 8080:8080
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health/ready"]
interval: 30s
timeout: 10s
retries: 3
volumes:
postgres_data:
Then run:
docker compose up -d
start instead of start-dev for production# View logs
docker logs -f <container-name>
# Enter container
docker exec -it <container-name> /bin/bash
# Check Keycloak version
docker run --rm quay.io/keycloak/keycloak:26.5.4 --version
# Get help
docker run --rm quay.io/keycloak/keycloak:26.5.4 --help
Running containers in production? We help with:
Need help? office@linux-server-admin.com or Contact Us