Dockerfiles in the Hello World Docker Demonstration

This topic describes in detail the commands used by the Dockerfile in 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 Dockerfiles.

Before reading this topic you should be familiar with the processes defined in Building a Base Image for Enterprise Server and Building an Image Containing an Application to Run Under Enterprise Server, and you need to have run the Docker demonstration xxxx to have created a base image for image for Enterprise Server.

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  # 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  FROM microfocus/cobolserver:rhel7_4.0_x64
006  
007  LABEL com.microfocus.is-base-image="false"
008  
009  RUN useradd -ms /bin/bash app
010  
011  ADD HelloWorld.tar.gz /home/app/
012  COPY ${MFLICFILE} /home/app/
013  
014  USER app
015  ENTRYPOINT /home/app/HelloWorld

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

Lines Description
005 Specifies the base image to use, which is the Enterprise Server base image.

On SUSE Linux the tag specified in the Dockerfile is sles12sp3_4.0_x64.

007 Specify the metadata labels for the image that will be created. These labels can be queried using the docker inspect command.
009 Runs the useradd command to add a new user called "app" with a login shell of /bin/bash.

On SUSE Linux, the corresponding action is achieved by a series of concatenated commands on lines 10 and 11.

011 - 012 Copies the files for the Hello World application into the /home/app folder in the image's filesystem.

On SUSE Linux the corresponding action is performed by the ADD command on line 14.

014 - 015 Sets the user name to be used when running the image and specifies that running the image executes the Hello World application.

On SUSE Linux these commands are on lines 17 through 19.