First, it uses the FROM instruction (which, apart from the ARG instruction) must be the first instruction in a Dockerfile. The FROM instruction defines the base image upon which we want to build our new image.
In this example, I chose the (what I believe to be) smallest Windows base image for Docker.
The WORKDIR instruction specifies the (image-) directory where we will operate. Because the base image does not have a C:\Work directory, it will be created.
Also, when we run a container on our created image, the working directory will be in the directory specified with WORKDIR.
The COPY instruction allows to copy a file from the host into the image, specifically to the directory that we specified with WORKDIR.
The file we copy, someCommands.bat will be the batch file that we want to execute when the image is run.
The content of someCommands.bat is:
@echo off
echo.
echo. This text is printed by someCommands.bat
echo.
echo. Value of TQ84_VAR is "%TQ84_VAR%"
echo.
echo. Current directory is %CD%
echo. Files in current directory are
dir /s /b
The ENV instruction creates an environment variable and assigns a value to it. someCommands.bat will echo this value.
I also ADD and COPY a zip and a tar file in order to demonstrate the difference between ADD and COPY. COPY always copies files without trying to expand them. ADD also copies files, except for tar files, which will be extracted.
With this Dockerfile, we can create an example with docker build: