-
Download and install Docker.
-
Login and switch to Windows Containers.
-
Go to Windows 'System Information' (Start -> System Information) and retrieve the version of Windows you are using under 'Version'.
-
Search for your Windows version on Microsoft's Windows Server Core Images section for using the correct image. For example, my version is 17134 so I search for 17134:
-
Any tag on the left most column can be used as long as the OsVersion lines up with your computer's version, for this example I use the tag '1803' as it was the simplest one and lined up with my version of 17134. You must use the correct tag otherwise it will fail to pull the image.
-
If you do not need to run the container on a set Ip Address, skip the Docker Network step and omit the --network and --ip options during container creation.
If you do not need to run the container on a set Ip Address, skip this step and omit the --network and --ip options during container creation.
The command to create a docker network is:
docker network create -d transparent --subnet=<subnet> --gateway=<gateway> <network name>For example:
docker network create -d transparent --subnet=192.168.1.0/25 --gateway=192.168.1.100 NetworkIf you do not need to run the container on a set Ip Address, omit the --network and --ip options. If you do, make sure you do the Docker Network step above first.
The command to create the container is:
docker run -it --name <container name> --network=<network name> --ip <ip> mcr.microsoft.com/windows/servercore:<servercore version>To get your servercore version, see Set-up.
For example:
docker run -it --name container --network=Network --ip 192.168.1.22 mcr.microsoft.com/windows/servercore:1803The command to starting running the container with Powershell is:
docker exec -it <container name> powershellIf you get an error that the container is not running, start the container:
docker start <container name>Copy all files needed to run the application into the docker container, then run the executable.
-
From inside the docker container, create a directory to contain all the files needed:
mkdir Application
-
Close the container and then stop it from the host:
docker stop <container name>
-
Move all files into the container from the solution's /bin/Release directory (or /bin/Debug if you do not have a Release). It is easiest to enter the directory, then move all files to your newly created directory in the container (make sure to put the path in quotations ("") if there are spaces in it during the copy command):
cd <path to your solution>/bin/Release docker cp . <container name>:C:/Application
If you ever get a "filesystem operations against a running container are not supported" error, then make sure to stop the container (see step 2 above).
-
Start and re-enter your container (see the Running the Container with Powershell step above).
-
From inside the container, navigate to your directory and check if all files were added:
cd Application ls -
Run the executable for your solution:
./Application.exe
docker container ls -adocker rm <container name>docker rename <current container name> <new container name>