The Dockerfile File in the Hello World Docker Demonstration

This topic lists and describes the Dockerfile file from the Hello World Docker demonstration. 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.

001  # Copyright (C) Micro Focus 2018. All rights reserved. 
002  # This sample code is supplied for demonstration purposes only
003  # on an "as is" basis and is for use at your own risk. 
004  
005  ARG DTAG
006  FROM microfocus/cobolserver:${DTAG}
007  
008  LABEL com.microfocus.is-example="true"
009  
010  # required arguments
011  ARG PLATFORM
012  
013  # optional arguments
014  ARG APPDIR=c:\\app
015  
016  # copy the application to the application directory
017  ADD HelloWorld_${PLATFORM}.zip "${APPDIR}\\"
018  
019  # set the start directory and the initial program name
020  WORKDIR "${APPDIR}"
021  
022  # unzip the .zip via powershell and cleanup
023  ENV PLATFORM=${PLATFORM}
024  RUN powershell -Command "Expand-Archive HelloWorld_%PLATFORM%.zip -DestinationPath %APPDIR%" && \
025      del HelloWorld_%PLATFORM%.zip
026  
027  # nullify the environment variables
028  ENV PLATFORM=""
029  ENV APPDIR=""
030  
031  # set the start 
032  ENTRYPOINT HelloWorld.exe

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

Lines Description
005 - 006 Specifies the base image to use, which is the COBOL Server base image.
008 Specify the metadata labels for the image that will be created. These labels can be queried using the docker inspect command.
011 - 014 Define build arguments passed by the docker build command:
  • PLATFORM. Either x86 or x64 indicating whether the Hello World application will be running in a 32-bit or 64-bit environment respectively.
  • APPDIR. Specifies the folder in the image's filesystem that the Hello World application is copied into. c:\app is used if this argument is not specified.
017 Copies a .zip file containing the pre-built Hello World executable file to the folder for the Hello World application in the image's filesystem.
020 Sets the Docker working directory to be the folder for the Hello World application in the image's filesystem.
023 Define the PLATFORM environment variable from the build argument of the same name that was defined earlier.
024 - 025 Run a series of concatenated Windows commands to unzip HelloWorld.exe then delete the .zip file.
028 - 029 Reset the environment variables that are no longer needed.
032 Specifies that running the image runs the Hello World application.