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.0) 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.

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?