How to build simple Iguana Docker Image
This document talks about:
More customers are deploying Iguana on the cloud and they are trying to figure whether Iguana can support container architecture
Containers offer increased portability (quickly spin up and down containers in any environment) and require less overhead than virtual machines (enables support for multiple applications on a single OS).
Even though there is no official Iguana container solution, here are some sample configurations and design that could get you started
Understand Container and Docker
What is a Container?
A container is a software package that contains everything the software needs to run, including the executable program as well as configuration files, libraries, and dependencies. In contrast to a Virtual Machine (VM), containers are isolated from the operating system (OS), and run on a “container platform”, such as Docker or Kubernetes, which is installed on the OS.
What is Docker?
Docker container technology was launched in 2013 as an open source Docker Engine. It leveraged existing computing concepts around containers and specifically in the Linux world. The key components of docker solutions includes:
Dockerfile: A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.
Docker registries: The Registry is a stateless, highly scalable server side application that stores and lets you distribute Docker images. The Registry is open-source, under the permissive Apache license. You can find the source code on GitHub.
Docker images: A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker container, like a template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM) environments.
Docker containers: Image result for docker container A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.
Solutions
Docker Solution Design
Sample Dockerfile
FROM redhat/ubi8
### Update redhat libraries (libidn is needed to start iguana service)
RUN yum -y update
RUN yum -y install procps
RUN yum -y install libidn.x86_64
RUN yum -y install jq
### Download, unzip, and run Iguana service
RUN cd /mnt && \
curl --insecure -L -o iguana_6_1_5_linux_centos7_x64.tar.gz https://dl.interfaceware.com/iguana/linux/6_1_5/iguana_6_1_5_linux_centos7_x64.tar.gz && \
tar -xvzf iguana_6_1_5_linux_centos7_x64.tar.gz
ENTRYPOINT ["/mnt/iNTERFACEWARE-Iguana/iguana", "--run"]
Sample Docker Build and Run Commands
## Build Docker Image from Dockerfile
docker build -t iguana-app:1.0 .
## Run Docker image with Iguana Dashboard and HTTP ports binding
docker run -p 8543:6543 -p 8544:6544 --name IguanaDocker -it iguana-app:1.0 bash
Consideration
Run shell script (.sh) in ENTRYPOINT
In the last line of Dockerfile, instead of run iguana directly, you could run a shell script instead
Doing so, you could execute more complex configuration after docker image has been build (ex. assigning license, update Iguana configuration location)
Auto assign Iguana License
With above dockerfile, once the docker container has started up. You will be navigated to Iguana License activation page.
If you require to auto assign Iguana license as part of dockerfile, you will need to do the following:
get IguanaID
get License code (IguanaToken)
Assign License code to Iguana
See sample code idea using curl below:
IguanaID=`$IguanaWorkingDir/6.1.5/iguana --id`
IguanaToken=`curl -k --request POST "https://my.interfaceware.com/api?username=$InterfacewareUser&password=$InterfacewarePassword&method=session.login" 2>/dev/null | grep "Token" | sed 's/",//' | sed 's/.*"//'`
EntitlementID=`curl -k --request POST "https://my.interfaceware.com/api?method=license.listentitlements&product=Iguana&token=$IguanaToken" 2>/dev/null | jq ".data[] | select(.name==\"$LicenseName\") | .id " | sed 's/"//g'`
IguanaLicense=`curl -k --request POST "https://my.interfaceware.com/api?method=license.activate&product=Iguana&token=$IguanaToken&description=IguanaLicense&entitlementid=$EntitlementID&instanceid=$IguanaID " 2>/dev/null | jq ".data | .code" | sed 's/"//g'`
You can reference Iguana License API for detail: IGUANA API Reference How to Build Iguana License Automation
Move Iguana Logs to Persisted Volume
Since docker container is perishable, configure Iguana logs inside docker container might be lost after docker container stopped.
A better architecture would set up a shared volume across different docker container and move Iguana logs into this shared volume.
See Volumes for detail
Reference