Install and Configure Keycloak using Docker


Keycloak is an Open Source Identity and Access Management solution for modern Applications and Services.

In this post, we will see how to install Keycloak using Docker and configure it to run our authentication service.

Install Keycloak

Make sure you have Docker installed before the next step.

From a terminal start Keycloak using the following command:


docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=password

This command will start Keycloak server on the local port 8080. It will also create an initial admin user with username admin and password password.

Configuring Keycloak

Visit the Keycloak Admin Console and login with the username and password we just created earlier.


Let's go ahead and create our first realm.

  1. Open the Keycloak Admin Console

  2. Hover the mouse over the dropdown in the top-left corner where it says Master, then click on Add realm

  3. Fill in the form with the following values:

    • Name: myrealm
  4. Click Create

💡 Hint

A realm allows us to create isolated groups of applications and users. By default there is a single realm in Keycloak called master. This is dedicated to manage Keycloak and should not be used for our own applications.

Then Wrap your App inside KeycloakProvider and pass the keycloak instance as prop

React (JS)

import React from 'react'; import { KeycloakProvider } from '@react-keycloak/web'; import keycloak from './keycloak'; // If you are using other providers (such as react-redux) it is recommended to place them inside KeycloakProvider. const App = () => { return ( <KeycloakProvider keycloak={keycloak}> <div className="App">{/* place your router or application here */}</div> </KeycloakProvider> ); };


asdasasdas dasjd asjk dals dla s