Dockerfiles in the Docker Demonstration for the Visual COBOL Base Image

This topic describes in detail the commands used by the Dockerfile in the Docker demonstration for the Visual COBOL base image. The Dockerfile is listed in its entirety and a following table describes the various Dockerfile commands. The line numbers in the listings of the Dockerfile have been added to aid readability. They are not present in the supplied Dockerfile.

Note: The Dockerfiles supplied for Red Hat Linux and SUSE Linux differ slightly. The Dockerfile shown below is the one supplied with Red Hat Linux. Where there are differences between the two versions they are described in the following table.
001  # Copyright (C) Micro Focus 2018. All rights reserved. 
002  
003  FROM rhel7/rhel:latest
004  
005  # PRODUCT_VERSION is product version associated with this Dockerfile
006  # ACCEPTEULA is the build-arg name for the acceptance of the end user license agreement
007  # SETUP_EXE is the build-arg name name of installer to used
008  # COBSRV_LOC is the build-arg name for the installation location
009  # MFLICFILE is the build-arg name for the license filename
010  ARG PRODUCT_VERSION=4.0.00
011  ARG ACCEPTEULA
012  ARG SETUP_EXE=setup_visualcobol_devhub_for_docker_4.0_redhat_x64
013  ARG LOGFILE=VisualCOBOLDevelopmentHub4.0.log
014  ARG MFLICFILE
015  
016  ARG ESADM_UID=500
017  ARG ESADM_GID=500
018  ARG ESADM_USER=esadm
019  ARG ESADM_SHELL=/bin/bash
020  
021  LABEL vendor="Micro Focus" \
022        com.microfocus.name="Visual COBOL" \
023        com.microfocus.version="$PRODUCT_VERSION" \
024        com.microfocus.eula.url="https://supportline.microfocus.com/licensing/agreements.aspx" \
025        com.microfocus.is-base-image="true" 
026  
027  ENV MFPRODBASE=/opt/microfocus/VisualCOBOL
028  ENV MFLICBASE=/var/microfocuslicensing
029  
030  # install ed, pax, gcc, gcc-c++, make and glibc-devel.x86_64 as these are a pre-req for the installer
031  RUN yum -y --disablerepo=rhel-7-server-rt-beta-rpms install ed pax gcc gcc-c++.x86_64 gdb glibc-devel.x86_64 make file
032  
033  # copy the installer from the local machine to the container
034  COPY ${SETUP_EXE} /tmp/${SETUP_EXE}
035  
036  # Create user esadm
037  RUN groupadd -f -g $ESADM_GID $ESADM_USER && \
038      useradd -u $ESADM_UID -g $ESADM_GID -m -s $ESADM_SHELL $ESADM_USER
039  
040  # ensure the setup exe has execute permissions and execute the setup
041  RUN chmod +x ./tmp/${SETUP_EXE} && \
042      (/tmp/$SETUP_EXE -${ACCEPTEULA} -ESadminID=$ESADM_USER || (echo ${LOGFILE} contains && touch ${LOGFILE} && cat ${LOGFILE} && exit 1)) && \
043      rm -f tmp/${SETUP_EXE} && \
044      echo "$MFPRODBASE/lib" >>/etc/ld.so.conf && \
045      ldconfig
046  
047  # install a license and remove the license file
048  COPY ${MFLICFILE} /tmp/
049  RUN cd /tmp && $MFLICBASE/bin/MFLicenseAdmin -install "${MFLICFILE}" && rm -f "${MFLICFILE}"
050  #
051  # clean up for containers that use -network:host
052  #
053  RUN  $MFLICBASE/bin/clean_guid_file

The commands on the lines in this Dockerfile are as follows:

Lines Description
003 Specifies the base image to use. For Red Hat this is the official Docker image for Red Hat Enterprise Linux.

For SUSE Linux this line is as follows:

FROM suse/sles12sp3

This specifies that the base image to use is the official Docker image for SUSE Linux Enterprise Server.

010 - 019 Define build arguments passed by the docker build command:
  • PRODUCT_VERSION.Indicates the version of Visual COBOL that this Dockerfile is supplied with.
  • SETUP.EXE. Specifies the name of the Visual COBOL installation file. The default setting is the name of the file supplied with Visual COBOL.
  • ACCEPTEULA. Indicates whether the terms of the Micro Focus End User License Agreement (EULA) have been accepted.
  • LOGFILE. Specifies the name to use for the log file created when installing Visual COBOL into the image.
  • MFLICFILE. Specifies the name of the license file to use for Visual COBOL.
  • ESADM_UID. Specifies the user ID to use for the Enterprise Server admin user.
  • ESADM_GID. Specifies the group ID to use for the Enterprise Server admin user.
  • ESADM_USER. Specifies the ID to be used for the Enterprise Server admin user.
  • ESADM_SHELL. Specifies the shell to use for the Enterprise Server admin user.
021 - 025 Specify the metadata labels for the image that will be created. These labels can be queried using the docker inspect command.
027 - 028 Create environment variables to be used in this Dockerfile:
  • MFPRODBASE. Specifies the folder into which Visual COBOL is installed.
  • MFLICBASE. Specifies the folder where the Micro Focus License Administration tool is installed.
031 Install software that is required to be able to install Visual COBOL.
033 Copy the installation file for Visual COBOL into a temporary folder.
037 - 038 Run a series of concatenated commands to add the Enterprise Server admin user and set up the shell to be used by that user.
041 - 045 Run a series of concatenated commands to perform the following actions:
  1. Make the Visual COBOL installation file executable.
  2. Run the Visual COBOL installation file using options to indicate acceptance of the license agreement and to specify the System Administrator Process User ID.
  3. Delete the temporary folder that you created earlier (containing the Visual COBOL installation file).
  4. Configure the dynamic linker run-time bindings to include the shared objects supplied with Visual COBOL.

    Doing this avoids the need to update the LD_LIBRARY_PATH environment variable.

048 - 049 Copy the license file to a temporary location, use it to license Visual COBOL, then delete the license file.
053 Run a script to reset the temporary file used when applying the license for Visual COBOL.