Creating Local KeyCloak Test Server

[1] Clone the Git Repository

Prepare a base directory.

cd ~
mkdir dockerkeycloaktest
cd dockerkeycloaktest

Git Clone.

git clone

The codes in the github repo is actually a local copy of the KeyCloak test page at

[2] Build Docker Image

cd localkeycloaktest

docker build -t localkeycloaktest .


Check that the image is listed in the Docker Desktop:

[3] Create and run a container from the image

Run a docker command to create a container with an interactive console (-it) that will be removed when it is terminated (--rm) which is mapped as port 88 (in host) to port 80 (in container) from the image name "localkeycloaktest".

docker run -it --rm -p 88:80 localkeycloaktest

Check that a container has been created:

[4] Configure KeyCloak Server

Assuming that you have already created myrealm, myclient and myuser according to the steps in the previous posts, configure the following settings:

  • Redirect URI : http://localhost:88/*

  • Web Origin: http://localhost:88

[5] Browse the LocalKeyCloakTest server page


Click the Save button.

Click Sign in.

Enter the credential myuser/Abcd1234

Open the Web Inspector panel and view the token data.

Click sign out.

[6] Terminate container session.

In the PowerShell console for the interactive container (in step 3), press [CTRL]+[C] to break and terminate the container session.

Once it is terminated, the container name will disappear from the container list in the Docker Desktop.