Overview

Skill Level: Any Skill Level

Architects, Developers

IntroductionThis recipe show cases the setup of docker image of Wildfly 10 application server along with keycloak server for SSO . This also show cases setting up of ssl on Wildfly which is one of the pre-reqs of opening keycloak server console on cloud with public IP. The intention of this article is to make […]

Ingredients

Knowledge of Docker concepts.

Knowledge of Dockerfile commands

Step-by-step

  1. Introduction

    This recipe show cases the setup of docker image of Wildfly 10 application server along with keycloak server for SSO . This also show cases setting up of ssl on Wildfly which is one of the pre-reqs of opening keycloak server console on cloud with public IP. The intention of this article is to make end user understand

    1.Setting up of base JDK to run wildfly. This will be supportive to run any Java based application environments.

    2. Steps behind the commands used in Dockerfile.

    3. How to import setup binary files in Docker container.

    4. How docker Image could be stored in Bluemix registry.

    To build and deploy the docker Image in commandless mode direclty on Bluemix one can refer the below article:

    https://developer.ibm.com/recipes/tutorials/creating-custom-docker-image-in-bluemix-partii/

    One can also refer the below article to attach other microservics to the docker container:

    https://developer.ibm.com/recipes/tutorials/binding-bluemix-services-to-ibm-containers-using-delivery-pipeline/

  2. Pre-requisites

    1. Wildfly 10 archive file.

    2. Keycloak Overlay archive file.

    3. JDK 1.8 archive file.

    4. A machine preferrebly ubuntu (for this article ubuntu 15 is used) with Docker environment Installed.

  3. Creating Base Setup Structure

    Before one start with docker Image setup one needs to create a base environment which is done by copying all the downloaded images of the software in the same folder and unzipping it parallel to the Dockerfile as shown in below Image.

  4. Creating a Docker Image

    To create a Docker Image one needs to write a Dockerfile to bring in setup files into Docker container and install them appropriately. In the Dockerfile in this case one needs to use COPY instructions to copy these directory to a particular location inside the newly created docker image, in our case this is jdk1.8.0_92 and wildfly root folders.

    Note: Make sure that unnecessary folders should not be there in current directory as it will halt container setup.

    To store the docker image in IBM Bluemix docker regiatry enter the below FROM command at the top of the Dockerfile.

    One need to download Image locally before making above reference. This can be downloaded using the command

    sudo docker pull registry.ng.bluemix.net:latest

    Using sudo docker images command one can list the images in local registry and verify the above downloaded Image.

    Copy the software archives into Docker Image.

    Note: Overwrite Keycloakoverlay contents with Wildfly by copy its content inside Wildfly folder while copying in Docker Image.

    Configure JDK and its necessary environment variables

    Create necessary wildfly users, expose admin and application port and start Wildfly

    Configurring SSL for Wildfly.

    Expose secure and unsecure ports

    Known Issue: While building Wildfly 10 Image with Keycloak server, one might get IllegalStateException as shown below. To rectify that one need to remove current and configuration folder after copying the content in docker Image.

     

     

  5. Building Docker Image

    Build and TAG the docker container with bluemix registry url using the created Dockerfile

     

    The tagged image could be seen using below command

    Upload the docker Image to IBM Bluemix using the below command:

    Once the Image upload has been completed the docker image could be seen in bluemix

    Once the container has been created one can click on the icon of the container to open the admin console.

    Click on the admin port to open wildfly admin console to deploy the applications.

     

  6. Conclusion

    Using above steps one can create a docker Image of Wildfly or any Java based application environment on local machine and upload it in Bluemix registry.

Join The Discussion