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.
The start-dev command explained
Section titled “The start-dev command explained”Here is what each part of the docker run command does:
docker run --name keycloak— names the container so you can reference it later withdocker stop keycloakordocker rm keycloak.-p 8080:8080— maps port 8080 on the host to port 8080 inside the container, sohttp://localhost:8080reaches Keycloak.-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.-e KC_BOOTSTRAP_ADMIN_PASSWORD=admin— sets the initial admin password. Change this in any real environment — never leave it asadminoutside of local dev.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.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-devOpening the admin console
Section titled “Opening the admin console”- Wait for the log line that says
Keycloak X.Y.Z on JVM (powered by Quarkus) started— this means Keycloak is ready. - Open
http://localhost:8080in your browser. - Click “Administration Console”.
- Sign in with username
adminand passwordadmin. - You are now in the master realm’s admin console.
Admin console vs account console
Section titled “Admin console vs account 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.
Stopping and removing the container
Section titled “Stopping and removing the container”# Stop the containerdocker stop keycloak# Remove the container (data is lost — this is dev mode)docker rm keycloakBecause 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.