DB2

Creating an IBM Db2 Docker image

You can create an IBM Db2 Docker image to simplify and expedite the deployment of new HCL Commerce runtime environments. It is recommended that you only use an IBM Db2 container in your test and quality assurance environments. Do not use an IBM Db2 container created in this method for your production environment.

The following procedure provides a guide to creating the image.
Note: The Db2 registry variable Db2_COMPATIBILITY_VECTOR is not supported.

Procedure

  1. Login to HCL License and Delivery portal.
  2. Download the Db2 package for the base operating system that you plan to use in your Docker container.
  3. Create a response file.
  4. Create an IBM Db2 specific start and stop script.
    The following script is provided to you as a reference. Modify as needed.
    Note: If the link does not prompt you to save, right-click and save the file.
  5. Create a Dockerfile with instructions to build the IBM Db2 Docker image.
    The following Dockerfile template is provided to you as a reference. You need to modify the file before it is usable.
    ##################################################################
    # IBM Confidential
    #
    # OCO Source Materials
    #
    # HCL Commerce
    #
    # (C) Copyright IBM Corp. 2016
    #
    # The source code for this program is not published or otherwise
    # divested of its trade secrets, irrespective of what has
    # been deposited with the U.S. Copyright Office.
    ##################################################################
    
    ## Part A: Define the base operating system
    # Dockerfile will create a base DB2 image
    # Using base image of CentOS latest
    FROM /library/centos:latest
    
    
    ## Part B Setup the environment with Libraries and set permissions to directories and 
    ## Adding dbadmin user and wcs user
    RUN yum install -y \
        pam \
        pam.i686 \
        ncurses-libs.i686 \
        file \
        libaio \
        libstdc++-devel.i686 && \
        yum clean all && \
        useradd -ms /bin/bash db2inst1 && \
        groupadd wcs && \
        useradd -g wcs wcs && \
        echo -e "wcs1\nwcs1\n" | passwd wcs
    
    # Part C # Environment variables are needed by the base DB2 image 
    # Specify a password for use db2inst1 
    
    ENV DB2INST1_PASSWORD passw0rd 
    ENV PATH /SETUP/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 
    ENV LD_LIBRARY_PATH /home/db2inst1/sqllib/lib64:/home/db2inst1/sqllib/lib64/gskit:/home/db2inst1/sqllib/lib32 
    
    # Part D 
    COPY SETUP /SETUP/ 
    
    # Part E, Extract, run the setup file, add license and delete the temporary files 
    RUN mkdir /SETUP/tmp/DB2INSTALLER && \
        curl -o /SETUP/tmp/DB2INSTALLER/DB2INSTALLER.tgz http://<library repository>/DB2/db2-wse-11.1.2.2.gz && \
        tar -xzf /SETUP/tmp/DB2INSTALLER/DB2INSTALLER.tgz -C /SETUP/tmp/DB2INSTALLER/ && \
        /SETUP/tmp/DB2INSTALLER/server_r/db2setup -r /SETUP/tmp/db2server.rsp && \
        /bin/su -c "db2licm -a /SETUP/tmp/DB2INSTALLER/server_r/db2/license/db2wse_o.lic" - db2inst1 && \
        /bin/su -c "db2licm -a /SETUP/tmp/DB2INSTALLER/server_r/db2/license/db2ef.lic" - db2inst1 && \
        chmod +x /SETUP/bin/* && \
        rm -r /SETUP/tmp
    
    
    # Part F 
    #Start the DB2 server and print out the diag log 
    ENTRYPOINT ["/bin/bash","/SETUP/bin/entrypoint.sh" ] 
    CMD [ "start" ] 
    
    # Part G # DB2 instance port 
    EXPOSE 50000 50001 
    
    In the Dockerfile, ensure that you specify the following instructions:
    1. Define the base operating system.
    2. Install library dependencies.
    3. Set related environment variables.
    4. Copy installation package and response file to docker image.
    5. Install the IBM Db2 server using a response file and add license files to accept the IBM Db2 terms and agreements.
    6. Define ENTRYPOINT instruction to point to the entrypoint.sh file and CMD with the command to run.
    7. Expose the IBM Db2 instance port.

Results

The IBM Db2 Docker image is created and ready to be used in a non-production test or development environment.