Skip to content

Run Keycloak with Docker

The fastest way to run Keycloak locally is with Docker. The official image on quay.io includes everything you need — no separate database, no install steps. One command and Keycloak is listening on port 8080.

Here is what each part of the docker run command does:

  1. docker run --name keycloak — names the container so you can reference it later with docker stop keycloak or docker rm keycloak.
  2. -p 8080:8080 — maps port 8080 on the host to port 8080 inside the container, so http://localhost:8080 reaches Keycloak.
  3. -e KC_BOOTSTRAP_ADMIN_USERNAME=admin — sets the initial admin username. This environment variable is only used on the very first boot when no admin account exists yet.
  4. -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin — sets the initial admin password. Change this in any real environment — never leave it as admin outside of local dev.
  5. quay.io/keycloak/keycloak:latest — the official Keycloak image from the Red Hat Quay registry. Pin to a specific version (e.g. 26.7) in CI or staging.
  6. start-dev — starts Keycloak in development mode with an embedded H2 in-memory database and HTTP enabled. No TLS certificate is required.
docker run --name keycloak -p 8080:8080 \
  -e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
  -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
  quay.io/keycloak/keycloak:latest start-dev
  1. Wait for the log line that says Keycloak X.Y.Z on JVM (powered by Quarkus) started — this means Keycloak is ready.
  2. Open http://localhost:8080 in your browser.
  3. Click “Administration Console”.
  4. Sign in with username admin and password admin.
  5. You are now in the master realm’s admin console.

The admin console (http://localhost:8080) is the management UI for administrators. You create realms, clients, users, roles, and identity providers here. Only team members who need to configure Keycloak should have access to it.

The account console (http://localhost:8080/realms/master/account) is the self-service portal for end users. Users can update their profile, change their password, and manage their active sessions here. Your application users land here, not the admin console. Each realm has its own account console at /realms/{realm-name}/account.

Terminal window
# Stop the container
docker stop keycloak
# Remove the container (data is lost — this is dev mode)
docker rm keycloak

Because start-dev uses an in-memory H2 database, all realms, clients, and users you created are gone when the container is removed. In the next module you will learn how to persist data with an external database.

OptionBenefitCost
start-dev in a Docker containerUp and running with one command, no database setup needed — good for experimenting and learningData is lost every time the container is removed, there’s no TLS, and it’s not fit for a real workload, even staging
start with an external database (production mode)Data persists across restarts/redeploys, supports TLS and a fixed hostname, and scales across multiple instancesRequires setting up a database, TLS certificate, and reverse proxy before it can be used
  • Running start-dev and forgetting to switch to start before going to production — start-dev disables several security checks and uses an in-memory database; forgetting to switch modes means production data disappears the moment the container restarts.
  • Not changing KC_BOOTSTRAP_ADMIN_USERNAME/KC_BOOTSTRAP_ADMIN_PASSWORD from the default — leaving admin/admin in place, even in a container exposed to another network, is a very common security gap.
  • Not pinning the image version — using quay.io/keycloak/keycloak:latest in CI or staging causes behaviour to change unexpectedly whenever a new version is released. Always pin to a specific version.

Real-world example

Platform engineering teams inside an organisation — commonly use docker run start-dev or docker-compose only on a developer’s local machine for integration testing, then deploy the real Keycloak through a Helm chart on Kubernetes with an external PostgreSQL database.

Red Hat build of Keycloak (RH-SSO) — the image used in this lesson is the community build; organisations that need an SLA-backed support contract use the Red Hat build of Keycloak container image instead, but the start/start-dev commands and environment variables work the same way.

What does the -p 8080:8080 flag do in the docker run command?
Which database does start-dev use?
What is the difference between the admin console and the account console?
What happens to your data when you docker rm the Keycloak container in start-dev mode?