9. HammerDB Docker Container Build & Run

Containers are lightweight prebuilt environments that are easy to distribute and deploy. Version 4.8 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 and recognised by the Docker Sponsored OSS program.

Figure 1.13. Docker Sponsored OSS

Docker Sponsored OSS

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

9.2. 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.14. Docker File Download

Docker File Download


9.3. 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.8 . 

Figure 1.15. docker build

docker build

Figure 1.16. Successfully built

Successfully built

9.4. 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.8 bash

Figure 1.17. docker run

docker run

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


9.4.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.18. IBM client

IBM client

9.5. 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.8 bash