Category Archives: Windows Container

Docker on Windows

Note: I’m going through draft posts that go back to 2014 and publishing where they still may have value. They may not be 100% upto date but better published late than never.

Up until recently I’ve been solely using Docker on Linux, but I’ve a need to use it with Windows now. I’ve installed Docker Desktop and set to Switch to Windows containers.

So first off we’re going to download a Windows image, whilst there are several variants, for server, nano windows, we’re going to go pretty much full blown using

docker pull mcr.microsoft.com/windows:2004

Note: It may take some time to download, it’s > 3GB

Now just to prove it worked let’s run it in interactive mode and starting the cmd prompt using

docker run -it mcr.microsoft.com/windows:2004 cmd.exe

Exit your image by typing exit followed by return.

I’m going to want to create a volume to save/share files with the Windows machine running the container, so let’s create a folder c:\shared and then copy or create a file in here, just to allow us to prove we can connect to it through the container, so mine’s predictably HelloWorld.txt, now run

docker run -it -v c:\shared:c:\shared mcr.microsoft.com/windows:2004 cmd.exe

Note: Change cmd.exe to powershell.exe if you prefer

I’m naming the folder in the image the same as the real machine’s folder, but you can change it to suit, just change the second path like this

docker run -it -v c:\shared:c:\shared2 mcr.microsoft.com/windows:2004 cmd.exe

and if you created a simple text file with a message in it, once we’re inside the container we can type

type HelloWorld.txt

from the c:\shared folder to see it it’s as expected.

Now I’m wanting to start to install applications into the container, but with no GUI we need “silent installs”

msiexec /i .\myapp.msi /QN /L*V install.log