# Self-host Keycloak

> An open-source identity and access management server with SSO, OAuth2, and SAML support.

- Page: https://levelrail.com/templates/keycloak/
- JSON: https://levelrail.com/templates/keycloak.json
- Category: Security
- Licence: Apache-2.0 (Permissive license)
- Source: https://github.com/keycloak/keycloak
- Upstream docs: https://www.keycloak.org/documentation

## Requirements
- Memory: about 1 GiB
- amd64: published, arm64: tested
- Needs configuration before start: no
- Pinned image tag: 26.1

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| keycloak | quay.io/keycloak/keycloak | 26.1 | 8080 | keycloak_data -> /opt/keycloak/data |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| keycloak | KC_BOOTSTRAP_ADMIN_PASSWORD | generated |
| keycloak | KC_BOOTSTRAP_ADMIN_USERNAME | generated |
| keycloak | KC_HEALTH_ENABLED | preset |
| keycloak | KC_HOSTNAME | preset |
| keycloak | KC_HTTP_ENABLED | preset |
| keycloak | KC_LEGACY_OBSERVABILITY_INTERFACE | preset |
| keycloak | KC_PROXY_HEADERS | preset |

## Deploy

### CLI

```bash
levelrail-cli templates deploy keycloak --name my-keycloak
```

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://levelrail.example.com/api/v1/service-templates/keycloak/deploy
```

Create a token in the dashboard first. This one-click route deploys it as a trial app you can keep or remove.

## Questions

### Can I deploy Keycloak on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list has an entry with the id keycloak for this app, so check that entry as well. Dokku deploys container images with its own commands, so the pinned image quay.io/keycloak/keycloak:26.1 is what you deploy there.

Self-host Keycloak, Keycloak docker compose file, deploy Keycloak on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
