Today I would like to show you how to get your first docker container running, what problems I had to fight with to bring it up and what commands you might need...
At first I thought the whole thing is very simple.
A small one-liner and we are at the goal....
# Running your first docker container -> "Hello World"
docker run hello-world
So there is a problem with the container, cause it doesn't match the hostoperatingsystem....
Apparently, the image for "hello-world" expects an operating system based on Linux.
As a result I try to built something here by my own.
Pulling down a windows based image...
# Pulling down an image
docker pull mcr.microsoft.com/windows/nanoserver:1903
Showing downloaded / created / installed images...
# Listing all downloaded / created / installed images
docker images
# or
docker image ls
# or
docker images -a
Removing unneeded images....
# Removing images
docker rmi <IMAGE ID>
docker rmi 01ede58bc7b8
# Forcing to remove images
docker rmi 01ede58bc7b8 -f
Running the Container...
# Trying to run the container and connect there interactively
docker run -it mcr.microsoft.com/windows/nanoserver:1903 cmd.exe
Curiously, there is also a compatibility problem here, although the image is windows based.
Trying to get a different windows container based on server core up an running.
# Pulling down an different image
docker pull mcr.microsoft.com/windows/servercore:ltsc2019
# Trying to run the container
docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 cmd.exe
Unfortunately, this again results in the same error....
I have just determined which Windows version I use exactly.
# Start cmd
cmd
ver
Trying to get a different windows container based on server core (which has been identified before) up an running.
Pulling down again...
# Pulling down an image
docker pull mcr.microsoft.com/windows/nanoserver:1903
# Pulling down an different image
docker pull mcr.microsoft.com/windows/servercore:10.0.19041.264
# Tagging the image
docker tag mcr.microsoft.com/windows/servercore:10.0.19041.264 microsoft/windowsservercore
Running the Container....
# Trying to run the container and connect there interactively
docker run -it microsoft/windowsservercore cmd.exe
That has now worked. So it is very important that the container matches the host system.
Listing all Containers....
# Showing all Container and the related status
docker ps -a
Creating a custom image...
Creating a new image from the running modified container
docker commit <containerid> helloworld
Showing downloaded / created / installed images again...
# Listing all installed / created / downloaded images
docker images
Removing unneeded containers...
# Removing a running container
docker rm 23933d090f26
Running the new image in a new container...
# Running the newly created image
docker run --rm helloworld cmd.exe /s /c type Hello.txt
Source: