This document consists of detailed steps about creating a Docker image for webMethods products and it is explained with an example of UM.
By Manoj Jannu, Senior Software Engineer, Software AG
Table of contents
- Overview
- Prerequisites
- Important Points To Be Considered
- Building a Sample Docker image for UM
- Running a webMethods product as a container
- Conclusion
Overview
This article describes detail steps about creating Docker images for webMethods products. The scripts and instructions contained in this article are for webMethods Product version 10.1 and above.
Prerequisites
- Minimum Knowledge of Docker and Dockerfile.
- Hands on experience on product installation scripts and images
- A new Linux machine. Preferably CentOS7 / RHEL with Docker installed
Important Points to Be Considered
Does product need an external database?
If product requires a database, make sure you are able to access the database from Docker daemon host to DB machine with respective port or you can have database as a container for this.
Need to keep data in a persistent file storage for products?
In case you want to keep a backup of files which is been used by products like log files, configuration etc., try to use volume mounted for containers.
Building a Sample Docker image for UM
As an example let’s a create Docker image for Universal Messaging and for this we need to
- Create a UM product installation image
- Create a product installation script to install products from image
Create a product installation image
You may be already familiar with the procedure to create a product installation image and script but in this document let’s describe those steps in detail.
Launch installer and create a UM image which we will be using for product installation in Docker container. Let’s name our product installation image as “UMInstallationImage”:
We have created a UM installation image.
Write a Product Installation Script
We will create a product installation script to install products from existing image. In our case it is a UM image.
Launch installer and create a script to install product from the image.
Goto “Advanced Option >Scripts” and provide details for installation script name and location.
Make sure to uncheck Install products on local machine.
Name our product installation script as “UmInstallationScript”:
Now from Image tab select an image which we have already created:
Proceed with other details like Hostname and installation directory and make sure to provide localhost as a Hostname:
Once you have created an installation script, make the required changes in the installation script like InstallDir, imageFile, HostName as required in the container. Notice that we have set HostName as ‘localhost’ which is nothing but the host name of Docker daemon:
Write a Dockerfile
Once we are done with Product installation image and script we would need to create a Dockerfile to pull a CentOS image and install required pre requisites like wget, java 1.8 for our product installation in the image.
Steps would be:
- Pull a Centos latest image from the Docker hub
- Install wget
- Download oracle jdk 1.8 tarball from official site. Here we will use a link currently available.
- Extract and set JAVA_HOME
- Add required files to filesystem of the image UmInstallationScript, SoftwareAGInstaller20180417.jar and UMInstallationImage.zip
- Install UM using installation script
- Add command to start UM when we launch a container
Our Dockerfile would look like:
From centos:latest
Maintainer Manoj Jannu
RUN yum install wget -y
RUN wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
RUN tar -zxvf jdk-8u131-linux-x64.tar.gz
ENV JAVA_HOME /jdk1.8.0_131
ENV PATH /jdk1.8.0_131/bin:$PATH
ADD UmInstallationScript /
ADD SoftwareAGInstaller20180417.jar /
ADD UMInstallationImage.zip /
RUN java -jar SoftwareAGInstaller20180417.jar -readScript ./testuminstallscript ;echo Succcesfully Installed;exit
CMD /opt/SoftwareAG/UniversalMessaging/server/umserver/bin/nserver
Save our dockerfile with the name ‘Dockerfile’.
Keep SoftwareAG Installer, Installation script, UM product installation image and Dockerfile in the same directory. Make sure you have given right path in the Dockerfile. i.e current directory:
Build a Docker Image from Dockerfile
Build a UM image from our Dockerfile by executing the following command from the location where we have kept our Dockerfile.
$docker build -t umimage:v10.1 .
OR
$docker build -t uumimage:v10.1 –f <dockerfilename>
You will notice following console output:
To verify, execute the following command which will list local images. Here you will see umimage has been created with the tag v10.1.
$docker images
Running Universal Messaging as a container
We will be using run command to spin a UM container. The Docker run command has a wide range of options that can be passed, which pretty much includes all capabilities of Docker.
Let’s keep a UM data directory in persistent storage using volume. In our example we will keep /opt/SoftwareAG/UniversalMessaging/server/umserver/data in volume with the name umdata.
Run UM container run as a daemon process which means Docker container would run in the background completely detached from your current shell for this –d is an option with run command.
$ docker run -d --name UM_Default -v umdata:/opt/SoftwareAG/UniversalMessaging/server/umserver/data -p 8000:9000 umimage:v10.1
Verify the running UM container
Execute docker ps command to list out running containers:
$docker ps
Console output shows our UM container is running and we can verify it in the UI:
http://<HostMachine>/<mappedport>.
i.e http://localhost:8000
Verify our Docker container data persisted in the volume
Since we have mounted UM data directory in the volume managed by Docker, we can check the contents from docker host machine located in the /var/lib/docker/volumes/umdata/_data.
$ sudo ls /var/lib/docker/volumes/umdata/_data
Console output shows docker log files and other files which are generated when we have start UM server. These files mounted in the host machine itself so that even we delete and recreate our docker container we will not lose UM data:
Let’s Create a queue from Enterprise manager to verify that data been written in to mounted volume:
A new file is created for UMContainerQueue in the /var/lib/docker/volumes/umdata/_data
Now delete and recreate the UM container. After recreating our docker container we still have UM channel persisted:
Conclusion
We have created a Docker image for universal messaging and likewise we can create a Docker image for any of webMethods product.