Setup Keycloak Docker Container

Docker is becoming main streamline to package and deploy self sufficient application containers. It wrap up a piece of software in a complete file system that contains everything it needs to run: code, run-time, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in. The same Linux kernel and libraries can be shared between multiple containers running on the host.

Please visit my blog previous blog Install Docker to setup docker.

Let’s Started

Docker hub provides images for all the software and tools. let’s find out the Keycloak docker image.

krishna@ubuntu:~$ docker search keycloak
NAME                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
jboss/keycloak                                                                            57                   [OK]
jboss/keycloak-postgres                                                                   9                    [OK]
jboss/keycloak-mysql                                                                      6                    [OK]
jboss/keycloak-ha-postgres                                                                5                    [OK]
jboss/keycloak-examples                                                                   4                    [OK]
jboss/keycloak-mongo                                                                      3                    [OK]
ggriffin924/keycloak                      Keycloak with Postgress and custom theme d...   1                    [OK]
kurzdigital/keycloak                      Keycloak server (H2)                            0                    [OK]
rxvallejoc/keycloak                       Keycloak                                        0                    [OK]
stefanreuter/keycloak                     JBoss Keycloak with support for PostgreSQL      0                    [OK]
dcm4che/keycloak                          keycloak based on 8-jre                         0                    [OK]
cloudrti/keycloak                         mongo based fork of jboss/keycloak with ne...   0                    [OK]
clinte/keycloak-openshift                 Keycloak on openshift                           0                    [OK]
thedigitalgarage/keycloak                 This is a special keycloak image                0                    [OK]
octoon/keycloak-centos                    keycloak centos                                 0                    [OK]
dklein/keycloak-nginx                     Reverse Proxy for dklein/keycloak Image         0                    [OK]
abacusresearch/keycloak-mysql-openshift   KeyCloak for OpenShift with MySQL support:...   0                    [OK]
dklein/keycloak                           Keycloak Server with MySQL Database and NG...   0                    [OK]
dmadk/keycloak-mysql-mc                   Keycloak instance for the Identity Broker ...   0                    [OK]
celsoagra/keycloak                        docker vm with keycloak                         0                    [OK]
dklein/keycloak-proxy                     Keycloak Proxy                                  0                    [OK]
computersciencehouse/keycloak             Extension of the official Keycloak Docker ...   0                    [OK]
maxird/keycloak                           Keycloak                                        0                    [OK]
jimmidyson/keycloak-openshift             Keycloak compatible with OpenShift              0                    [OK]
msiegenthaler/keycloak                    Keycloak - forked to add SSL                    0                    [OK]
krishna@ubuntu:~$ 

There are many Keycloak Docker images available, but it is always better to go with the official release. As they are highly optimised, bug free and stable. You can download to your computer using pull command. After that we can list down the docker images. Let’s go with jboss/keycloak.

krishna@ubuntu:~$ sudo docker pull jboss/keycloak
Using default tag: latest
latest: Pulling from jboss/keycloak
93857f76ae30: Pull complete 
cde6403934ad: Pull complete 
f847b784f425: Pull complete 
ab2339d8111f: Pull complete 
1b434e9113ea: Pull complete 
cb341d1a61e9: Pull complete 
8c71c94db229: Pull complete 
71b2542b1441: Pull complete 
c91eb89580ac: Pull complete 
Digest: sha256:dc6573dcc6e3faca50a32d178d022ce85454c6f5d0fbe9fb039ff160564e5865
Status: Downloaded newer image for jboss/keycloak:latest
krishna@ubuntu:~$ 
krishna@ubuntu:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
jboss/keycloak      latest              191d8ef99c8b        3 days ago          643MB
mongo               latest              6329fba85f65        6 days ago          360MB
mysql               latest              d5127813070b        2 weeks ago         407MB
hello-world         latest              48b5124b2768        3 months ago        1.84kB
krishna@ubuntu:~$ 

Run Keycloak Container

After an image has been downloaded, you may then run a container using the downloaded image with the run sub command. If an image has not been downloaded when docker is executed with the run sub command, the Docker client will first download the image, then run a container using it.

krishna@ubuntu:~$ docker run --name sso -d jboss/keycloak
9a46193f7a0cda22bda931785b9b8309ca740d09ba48e671ca7d658aaf38692e
krishna@ubuntu:~$ 
krishna@ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
9a46193f7a0c        jboss/keycloak      "/opt/jboss/docker..."   7 seconds ago       Up 6 seconds        8080/tcp            sso
krishna@ubuntu:~$ 
krishna@ubuntu:~$ 
krishna@ubuntu:~$ docker logs sso
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/keycloak

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

04:17:15,852 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.1.Final
04:17:16,216 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
04:17:16,306 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: Keycloak 3.1.0.CR1 (WildFly Core 2.0.10.Final) starting
04:17:18,456 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
04:17:18,496 INFO  [org.xnio] (MSC service thread 1-2) XNIO version 3.3.4.Final
04:17:18,515 INFO  [org.xnio.nio] (MSC service thread 1-2) XNIO NIO Implementation Version 3.3.4.Final
04:17:18,603 INFO  [org.jboss.remoting] (MSC service thread 1-2) JBoss Remoting version 4.0.18.Final
04:17:18,649 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) WFLYCLINF0001: Activating Infinispan subsystem.
04:17:18,675 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 2 core threads with 16 task threads based on your 1 available processors
04:17:18,710 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) WFLYJSF0007: Activated the following JSF Implementations: [main]
04:17:18,716 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) WFLYNAM0001: Activating Naming Subsystem
04:17:18,744 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 45) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique.
04:17:18,759 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) WFLYSEC0002: Activating Security Subsystem
04:17:18,834 INFO  [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.2.Final)
04:17:18,883 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 46) WFLYUT0003: Undertow 1.3.15.Final starting
04:17:18,938 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
04:17:18,993 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0003: Undertow 1.3.15.Final starting
04:17:19,008 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = h2
04:17:19,103 INFO  [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=4.9.4.Final
04:17:19,106 INFO  [org.jboss.as.naming] (MSC service thread 1-2) WFLYNAM0003: Starting Naming Service
04:17:19,196 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
04:17:19,219 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 46) WFLYUT0014: Creating file handler for path '/opt/jboss/keycloak/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
04:17:19,472 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 16 (per class), which is derived from thread worker pool sizing.
04:17:19,473 INFO  [org.jboss.as.ejb3] (MSC service thread 1-1) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 4 (per class), which is derived from the number of CPUs on this host.
04:17:19,604 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0012: Started server default-server.
04:17:19,791 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on 0.0.0.0:8080
04:17:19,793 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
04:17:20,205 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/KeycloakDS]
04:17:20,325 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory /opt/jboss/keycloak/standalone/deployments
04:17:20,330 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
04:17:20,329 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "keycloak-server.war" (runtime-name: "keycloak-server.war")
04:17:20,641 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-1) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
04:17:20,639 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Mahou' 8.1.0.Final
04:17:21,701 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 48) WFLYCLINF0002: Started authorization cache from keycloak container
04:17:21,706 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 49) WFLYCLINF0002: Started realms cache from keycloak container
04:17:21,705 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 55) WFLYCLINF0002: Started loginFailures cache from keycloak container
04:17:21,705 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 52) WFLYCLINF0002: Started sessions cache from keycloak container
04:17:21,705 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 51) WFLYCLINF0002: Started users cache from keycloak container
04:17:21,704 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 53) WFLYCLINF0002: Started keys cache from keycloak container
04:17:21,712 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 54) WFLYCLINF0002: Started work cache from keycloak container
04:17:21,698 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 50) WFLYCLINF0002: Started offlineSessions cache from keycloak container
04:17:23,452 INFO  [org.keycloak.services] (ServerService Thread Pool -- 48) KC-SERVICES0001: Loading config from standalone.xml or domain.xml
04:17:25,588 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 48) WFLYCLINF0002: Started realmRevisions cache from keycloak container
04:17:25,609 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 48) WFLYCLINF0002: Started userRevisions cache from keycloak container
04:17:29,795 INFO  [org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider] (ServerService Thread Pool -- 48) Initializing database schema. Using changelog META-INF/jpa-changelog-master.xml
04:17:32,676 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 48) HHH000204: Processing PersistenceUnitInfo [
	name: keycloak-default
	...]
04:17:32,776 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 48) HHH000412: Hibernate Core {5.0.7.Final}
04:17:32,788 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 48) HHH000206: hibernate.properties not found
04:17:32,790 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 48) HHH000021: Bytecode provider name : javassist
04:17:32,842 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 48) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
04:17:33,094 INFO  [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 48) HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
04:17:33,104 WARN  [org.hibernate.dialect.H2Dialect] (ServerService Thread Pool -- 48) HHH000431: Unable to determine H2 database version, certain features may not work
04:17:33,167 INFO  [org.hibernate.envers.boot.internal.EnversServiceImpl] (ServerService Thread Pool -- 48) Envers integration enabled? : true
04:17:34,338 INFO  [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 48) HV000001: Hibernate Validator 5.2.3.Final
04:17:36,274 INFO  [org.hibernate.hql.internal.QueryTranslatorFactoryInitiator] (ServerService Thread Pool -- 48) HHH000397: Using ASTQueryTranslatorFactory
04:17:38,084 INFO  [org.keycloak.services] (ServerService Thread Pool -- 48) KC-SERVICES0050: Initializing master realm
04:17:40,747 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.keycloak.services.resources.KeycloakApplication
04:17:40,763 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002200: Adding class resource org.keycloak.services.resources.JsResource from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,763 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002205: Adding provider class org.keycloak.services.filters.KeycloakTransactionCommitter from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,763 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002200: Adding class resource org.keycloak.services.resources.ThemeResource from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,764 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.ServerVersionResource from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,764 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.RealmsResource from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,764 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.RobotsResource from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,766 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.admin.AdminRoot from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,766 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.WelcomeResource from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,767 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 48) RESTEASY002210: Adding provider singleton org.keycloak.services.util.ObjectMapperResolver from Application class org.keycloak.services.resources.KeycloakApplication
04:17:40,935 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 48) WFLYUT0021: Registered web context: /auth
04:17:41,002 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 47) WFLYSRV0010: Deployed "keycloak-server.war" (runtime-name : "keycloak-server.war")
04:17:41,202 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
04:17:41,203 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
04:17:41,204 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: Keycloak 3.1.0.CR1 (WildFly Core 2.0.10.Final) started in 25867ms - Started 425 of 783 services (526 services are lazy, passive or on-demand)
krishna@ubuntu:~$ 

Looks good. Our Keycloak Container is running now. As per the details from above logs.

Let’s verify the status of the container.

krishna@ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
9a46193f7a0c        jboss/keycloak      "/opt/jboss/docker..."   3 minutes ago       Up 3 minutes        8080/tcp            sso
krishna@ubuntu:~$ 

Keycloak container is now running and accessible on port 8080 of that container. Use the following command to see what happened during the container startup:

krishna@ubuntu:~$ docker logs sso

Connecting to Container

Next, we can get detailed info about the Keycloak container named sso. Run the inspect command:

krishna@ubuntu:~$ docker inspect sso
[
 {
 "Id": "9a46193f7a0cda22bda931785b9b8309ca740d09ba48e671ca7d658aaf38692e",
 "Created": "2017-05-01T04:17:15.045112776Z",
 "Path": "/opt/jboss/docker-entrypoint.sh",
 "Args": [
 "-b",
 "0.0.0.0"
 ],
 "State": {
 "Status": "running",
 "Running": true,
 "Paused": false,
 "Restarting": false,
 "OOMKilled": false,
 "Dead": false,
 "Pid": 3643,
 "ExitCode": 0,
 "Error": "",
 "StartedAt": "2017-05-01T04:17:15.245330344Z",
 "FinishedAt": "0001-01-01T00:00:00Z"
 },
 "Image": "sha256:191d8ef99c8b90be506870ea8a06f509a93e2e34172cf7f9aa21825cd59593c4",
 "ResolvConfPath": "/var/lib/docker/containers/9a46193f7a0cda22bda931785b9b8309ca740d09ba48e671ca7d658aaf38692e/resolv.conf",
 "HostnamePath": "/var/lib/docker/containers/9a46193f7a0cda22bda931785b9b8309ca740d09ba48e671ca7d658aaf38692e/hostname",
 "HostsPath": "/var/lib/docker/containers/9a46193f7a0cda22bda931785b9b8309ca740d09ba48e671ca7d658aaf38692e/hosts",
 "LogPath": "/var/lib/docker/containers/9a46193f7a0cda22bda931785b9b8309ca740d09ba48e671ca7d658aaf38692e/9a46193f7a0cda22bda931785b9b8309ca740d09ba48e671ca7d658aaf38692e-json.log",
 "Name": "/sso",
 "RestartCount": 0,
 "Driver": "aufs",
 "MountLabel": "",
 "ProcessLabel": "",
 "AppArmorProfile": "docker-default",
 "ExecIDs": null,
 "HostConfig": {
 "Binds": null,
 "ContainerIDFile": "",
 "LogConfig": {
 "Type": "json-file",
 "Config": {}
 },
 "NetworkMode": "default",
 "PortBindings": {},
 "RestartPolicy": {
 "Name": "no",
 "MaximumRetryCount": 0
 },
 "AutoRemove": false,
 "VolumeDriver": "",
 "VolumesFrom": null,
 "CapAdd": null,
 "CapDrop": null,
 "Dns": [],
 "DnsOptions": [],
 "DnsSearch": [],
 "ExtraHosts": null,
 "GroupAdd": null,
 "IpcMode": "",
 "Cgroup": "",
 "Links": null,
 "OomScoreAdj": 0,
 "PidMode": "",
 "Privileged": false,
 "PublishAllPorts": false,
 "ReadonlyRootfs": false,
 "SecurityOpt": null,
 "UTSMode": "",
 "UsernsMode": "",
 "ShmSize": 67108864,
 "Runtime": "runc",
 "ConsoleSize": [
 0,
 0
 ],
 "Isolation": "",
 "CpuShares": 0,
 "Memory": 0,
 "NanoCpus": 0,
 "CgroupParent": "",
 "BlkioWeight": 0,
 "BlkioWeightDevice": null,
 "BlkioDeviceReadBps": null,
 "BlkioDeviceWriteBps": null,
 "BlkioDeviceReadIOps": null,
 "BlkioDeviceWriteIOps": null,
 "CpuPeriod": 0,
 "CpuQuota": 0,
 "CpuRealtimePeriod": 0,
 "CpuRealtimeRuntime": 0,
 "CpusetCpus": "",
 "CpusetMems": "",
 "Devices": [],
 "DeviceCgroupRules": null,
 "DiskQuota": 0,
 "KernelMemory": 0,
 "MemoryReservation": 0,
 "MemorySwap": 0,
 "MemorySwappiness": -1,
 "OomKillDisable": false,
 "PidsLimit": 0,
 "Ulimits": null,
 "CpuCount": 0,
 "CpuPercent": 0,
 "IOMaximumIOps": 0,
 "IOMaximumBandwidth": 0
 },
 "GraphDriver": {
 "Data": null,
 "Name": "aufs"
 },
 "Mounts": [],
 "Config": {
 "Hostname": "9a46193f7a0c",
 "Domainname": "",
 "User": "jboss",
 "AttachStdin": false,
 "AttachStdout": false,
 "AttachStderr": false,
 "ExposedPorts": {
 "8080/tcp": {}
 },
 "Tty": false,
 "OpenStdin": false,
 "StdinOnce": false,
 "Env": [
 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
 "JAVA_HOME=/usr/lib/jvm/java",
 "KEYCLOAK_VERSION=3.1.0.CR1",
 "LAUNCH_JBOSS_IN_BACKGROUND=1",
 "JBOSS_HOME=/opt/jboss/keycloak"
 ],
 "Cmd": [
 "-b",
 "0.0.0.0"
 ],
 "ArgsEscaped": true,
 "Image": "jboss/keycloak",
 "Volumes": null,
 "WorkingDir": "/opt/jboss",
 "Entrypoint": [
 "/opt/jboss/docker-entrypoint.sh"
 ],
 "OnBuild": null,
 "Labels": {
 "build-date": "20170406",
 "license": "GPLv2",
 "name": "CentOS Base Image",
 "vendor": "CentOS"
 }
 },
 "NetworkSettings": {
 "Bridge": "",
 "SandboxID": "86016484b9093deb45d302c5fdae6adc3c9f62cca0b0463ad2d8efa43424e472",
 "HairpinMode": false,
 "LinkLocalIPv6Address": "",
 "LinkLocalIPv6PrefixLen": 0,
 "Ports": {
 "8080/tcp": null
 },
 "SandboxKey": "/var/run/docker/netns/86016484b909",
 "SecondaryIPAddresses": null,
 "SecondaryIPv6Addresses": null,
 "EndpointID": "0e8a742a0af21f212e033feef99fdf48b95477a973aceb9152db095e87c863cc",
 "Gateway": "172.17.0.1",
 "GlobalIPv6Address": "",
 "GlobalIPv6PrefixLen": 0,
 "IPAddress": "172.17.0.2",
 "IPPrefixLen": 16,
 "IPv6Gateway": "",
 "MacAddress": "02:42:ac:11:00:02",
 "Networks": {
 "bridge": {
 "IPAMConfig": null,
 "Links": null,
 "Aliases": null,
 "NetworkID": "7a367ae13a2468b97511223b6e791f99e11d7d31821c0f42ad52466004531817",
 "EndpointID": "0e8a742a0af21f212e033feef99fdf48b95477a973aceb9152db095e87c863cc",
 "Gateway": "172.17.0.1",
 "IPAddress": "172.17.0.2",
 "IPPrefixLen": 16,
 "IPv6Gateway": "",
 "GlobalIPv6Address": "",
 "GlobalIPv6PrefixLen": 0,
 "MacAddress": "02:42:ac:11:00:02"
 }
 }
 }
 }
]
krishna@ubuntu:~$

Access Method

Your command prompt should change to reflect the fact that you’re now working inside the container and should take this form

[jboss@9a46193f7a0c ~]$

Now you may run any command inside the container.

krishna@ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
9a46193f7a0c        jboss/keycloak      "/opt/jboss/docker..."   8 minutes ago       Up 8 minutes        8080/tcp            sso
krishna@ubuntu:~$ 
krishna@ubuntu:~$ docker exec -it sso bash
[jboss@9a46193f7a0c ~]$ 

Keycloak Dashboard

Conclusion

VOWW…. We now have a Keyclaok instance running in a container.

Docker allocates a dynamic IP address on every running container. Whenever a container is restarted, you will get a new IP address. You can get the IP address range from the Docker network interface in the Linux box. To sort this issue there is an option called –link

One Comment

  1. Krishna Prajapati

    krishna@ubuntu:~$ docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin –name sso -d jboss/keycloak

Leave a Reply

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