9. HammerDB Docker Container Build & Run

Containers are lightweight prebuilt environments that are easy to distribute and deploy. Version 4.11 includes both a pre-built Docker Image and a Dockerfile that can be used to create a HammerDB Docker containers. This container is based on an Ubuntu 20.04 base image and provides a ready to use environment to run HammerDB. HammerDB has a dependency on 3rd party driver libraries to connect to the target databases. This docker container installs the required client libraries and sets up the environment that enables connections to the target databases.

9.1. Docker Image

A pre-built Docker image is provided on the official TPC site on Docker Hub at https://hub.docker.com/u/tpcorg than be downloaded with the docker pull command either for a complete image for all databases but also database specific images.

docker pull tpcorg/hammerdb
docker pull tpcorg/hammerdb:mysql
docker pull tpcorg/hammerdb:maria
docker pull tpcorg/hammerdb:oracle
docker pull tpcorg/hammerdb:postgres
docker pull tpcorg/hammerdb:mssqls

The official HammerDB Docker images are hosted by the TPC-Council.

Figure 1.13. HammerDB Docker Hub

HammerDB Docker Hub

It is only necessary to follow the Dockerfile build instructions if you wish to build your own Dockerfile from source.

9.2. CloudTK Web Application Docker Image

HammerDB provides an additional Docker image for running the HammerDB GUI as a Web Application accessed through a web browser. This is particularly useful running in a cloud environment where a local Desktop environment is not readily available. f you want access to functionality such as CPU metrics then you should use the –net-host option.

$ sudo docker run --net=host --name hammerdb-cloudtk tpcorg/hammerdb:latest-cloudtk
can't find package limit
Running with default file descriptor limit
/debug user "debug" password "sycu4xfc.gcw"
httpd started on port 8081
secure httpd started on SSL port 8082

Otherwise you can only expose the ports as needed.

docker run -p 8081:8081 -p 8082:8082 -p 8080:8080 --name hammerdb-cloudtk hammerdb:cloudtk

You can connect to port 8081 for an unencrypted connection. Alternatively you can use an encrypted connection on port 8082. By default sample self-signed certificates are installed and these should be replaced by your own.

Figure 1.14. CloudTK Launcher

CloudTK Launcher

Click Submit Query on the Launcher.

Figure 1.15. Launch HammerDB

Launch HammerDB

HammerDB will then run fully contained within a browser, giving access to the GUI from cloud environments where the Desktop may not be readily available.

Figure 1.16. HammerDB GUI within a browser

HammerDB GUI within a browser

9.3. Dockerfile Download and installation

A Dockerfile is a shell script that automates the docker container build. It makes it easier to spawn multiple containers with ease. HammerDBv-4.6 source on GitHub is packaged with a folder “Docker”, that contains all the Docker related files and folders. This folder contains a Dockerfile for building a HammerDB client container that supports all the databases that HammerDB supports, i.e. Oracle, Microsoft SQL Server, IBM Db2, MySQL, PostgreSQL and MariaDB. Dockerfile is easy to customize each one’s requirement.

The HammerDB Dockerfile is stored within the HammerDB GitHub repository. To download the Dockerfile either Clone or Download the ZIP of the the HammerDB source and navigate to the Docker directory.

Figure 1.17. Docker File Download

Docker File Download


9.4. Building the HammerDB Container

The Docker container built from this Dockerfile installs the required 3rd party driver libraries for all databases supported in HammerDB except for IBM Db2. As IBM Db2 client libraries are not free to redistribute they must be independently downloaded and added if required. For the build to include IBM Db2, IBM Data Server Driver for ODBC and CLI version 11.5.6 can be downloaded locally and placed in the same location as Dockerfile.

To create an image: Go to the folder containing the Dockerfile and run the docker build command.

docker build -t hammerdb-v4.11 . 

Figure 1.18. docker build

docker build

Figure 1.19. Successfully built

Successfully built

9.5. Running the Container

To create and start a container named "hammerdb" with the image built in previous section run the following command. The container build is successful but the client libraries for IBM are not installed.

	docker run -it --name hammerdb hammerdb-v4.11 bash

Figure 1.20. docker run

docker run

If IBM client libraries are manually downloaded and placed alongside Dockerfile, container builds successfully and output looks as follows.


9.5.1. IBM Client install

If IBM client libraries are manually downloaded and placed alongside Dockerfile, container builds successfully and output looks as follows.

Figure 1.21. IBM client

IBM client

9.6. Connecting the Container to the Network

The docker container needs to be connected to network to communicate with remote databases. The following is an example of adding host network to the container.

 docker run --network=host -it --name hammerdb hammerdb-v4.11 bash