Search notes:

Simple Dockerfile example

The following simple Dockerfile tries to demonstrate a few basic Dockerfile instructions:
FROM         mcr.microsoft.com/windows/nanoserver:1809
WORKDIR      C:/work 
COPY         someCommands.bat .

ENV          TQ84_VAR Hello World

#            COPY always copies files, never extracts archives:
COPY         copied.zip       .
COPY         copied.tar       .

#            ADD extracts tar archives, but not zip archives:
ADD          added.zip        .
ADD          added.tar        .

ENTRYPOINT ["cmd.exe", "/c", "someCommands.bat"]
Github repository about-Docker, path: /Dockerfile/simple/Dockerfile
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
Github repository about-Docker, path: /Dockerfile/simple/someCommands.bat
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:
P:\ath\to\example> docker build -t simple-dockerfile-example .
After building the image, we see it like so:
P:\ath\to\example> docker images
Finally, we can run the image:
P:\ath\to\example> docker run simple-dockerfile-example

Linux: no matching manifest for linux/amd64 in the manifest list entries

When trying this example on LInux, the docker build command threw no matching manifest for linux/amd64 in the manifest list entries.

Index