Configuring a password for KeyCloak running in Docker. 1


Starting up keycloak in a docker container using docker for windows can be a bit tricky the first time you try. For me the main issues were waiting for the container to start up and setting the admin password.

Docker Hub container

I have been using this Keycloak docker image found on docker hub Jboss/KeyCloak. The image itself as directions on how to install it but I have a few tips.

Boot it

There are a few things that you can do to change the ports. I peronally found that just booting it in standalone mode worked the best for my setup.

To boot in standalone mode

docker run jboss/keycloak

This gives us a very basic default version of keycloak

It will be running on port 8080

Wait

When you run the command above it will take a minute for the container to start. Once you see the text scrolling on the screen you know that the container has started. I found that the Status from a docker ps was not actuate in displaying the status of the container.

Password

By default this version will not have an admin password which means that you wont be able to use the admin UI. To add a password we will need to do the following.

docker exec <CONTAINER> /opt/jboss/keycloak/bin/add-user-keycloak.sh -u <USERNAME> -p <PASSWORD>

This will create a password in your already running container. Remember you do docker ps to find the container id of your running container.

Once that command has run you will need to restart the container this can be done by stopping it and then restarting it.

docker stop <CONTAINER>
docker start <CONTAINER> -a

The -a just attaches the output to the container so that we can watch and wait for it to complete starting. Once you know its working you will not need to do that.

Once you see the following you should know its all up and running

You can then navigate to http://localhost:8080/auth/admin in your web browser and login to the admin section of keycloak.


About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as an application developer and a database expert. I have also been working with Google APIs since 2012 and I have been contributing to the Google .Net client library since 2013. In 2013 I became a a Google Developer Experts for Google Analytics.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “Configuring a password for KeyCloak running in Docker.