Get started with Keycloak on Docker

Before you start

Make sure you have Docker installed.

Start Keycloak

From a terminal, enter the following command to start Keycloak:

docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin start-dev

This command starts Keycloak exposed on the local port 8080 and creates an initial admin user with the username admin and password admin.

Log in to the Admin Console

  1. Go to the Keycloak Admin Console.

  2. Log in with the username and password you created earlier.

Create a realm

A realm in Keycloak is equivalent to a tenant. Each realm allows an administrator to create isolated groups of applications and users. Initially, Keycloak includes a single realm, called master. Use this realm only for managing Keycloak and not for managing any applications.

Use these steps to create the first realm.

  1. Open the Keycloak Admin Console.

  2. Click the word master in the top-left corner, then click Create realm.

  3. Enter myrealm in the Realm name field.

  4. Click Create.

Add realm

Create a user

Initially, the realm has no users. Use these steps to create a user:

  1. Open the Keycloak Admin Console.

  2. Click Users in the left-hand menu.

  3. Click Create new user.

  4. Fill in the form with the following values:

    • Username: myuser

    • First name: any first name

    • Last name: any last name

  5. Click Create.

Create user

This user needs a password to log in. To set the initial password:

  1. Click Credentials at the top of the page.

  2. Fill in the Set password form with a password.

  3. Toggle Temporary to Off so that the user does not need update this password at the first login.

Set password

Log in to the Account Console

You can now log in to the Account Console to verify this user is configured correctly.

  1. Open the Keycloak Account Console.

  2. Log in with myuser and the password you created earlier.

As a user in the Account Console, you can manage your account including modifying your profile, adding two-factor authentication, and including identity provider accounts.

Keycloak Account Console

Secure the first application

To secure the first application, you start by registering the application with your Keycloak instance:

  1. Open the Keycloak Admin Console.

  2. Click Clients.

  3. Click Create client

  4. Fill in the form with the following values:

    • Client type: OpenID Connect

    • Client ID: myclient

  5. Click Next

  6. Confirm that Standard flow is enabled.

  7. Click Save.

Add Client

After the client is created, make these updates to the client:

  1. Scroll down to Access settings.

    • Set Valid redirect URIs to*

    • Set Web origins to

  2. Click Save.

Update Client

To confirm the client was created successfully, you can use the SPA testing application on the Keycloak website.

  1. Open

  2. Click Save to use the default configuration.

  3. Click Sign in to authenticate to this application using the Keycloak server you started earlier.

Taking the next step

Before you run Keycloak in production, consider the following actions:

  • Switch to a production ready database such as PostgreSQL.

  • Configure SSL with your own certificates.

  • Switch the admin password to a more secure password.

For more information, see the server guides.

On this page