Docker container for windows

    Its been a long time since I wrote a post, but this one caught me out a few more times than I care to remember, so I thought it worth a post

    So the context of this article is that we have some legacy code that is NOT .Net Core, We need to run this code in Docker. So that means we have to run a full .NET compatible docker base image to run .NET 4.7.2

    Sounds simple enough right?

    Well yes and no, did I mention

    • That we are using Kubernetes on AWS (EKS, where we have a cluster of Windows and Linux based AMI EC2 instances)

    • We need to use Windows Containers not Linux ones

    • That all devs have a fixed machine that is not a VM, and it has a specific version of windows, this is important

        • Ok lets park that for a minute, lets assume we have a .NET Framework project (lets called it a WebApi project for simplicity) that we want to Dockerize

          Ok cool, so lets craft a docker file, maybe something like this

        ADD . /app
        WORKDIR /app
        RUN DIR
        ENTRYPOINT "WebApiService.exe"

        So when I ran this locally all was great. So then I tried to prepare it for EKS where we would run in on a shared EKS cluster, where we have Linux and Windows EC2 instances. And them I got this

        The operating system of the container does not match the operating system of the host

        Hmm this worked locally what could be wrong? lets dig on that

        So if I run this command locally on MY DEV VM I get this from PowerShell


        I get this

        Major  Minor  Build  Revision
                    -----  -----  -----  --------
                    10     0      17134  0

        Hmm ok

        So this is interesting lets keep digging, Now that we have this, we can check this against these known Docker base images where you may need to refer to this page to find your version in the list, and then

        That should give you a number like 1803. Which is based on the Major/Build number of your OSVersion, see how that is 10.0.17134 which matches my DEV machine, this is why it the docker base image runtime:4.8-windowsservercore-1803 works from my VM

                    1803     multiarch           No Dockerfile    10.0.17134.1305 10/06/2018 05:11:43      02/19/2020 02:35:44

        Which leads to this base image for our Dockerfile ``

        OK great, so why wont it work in AWS EKS??? Lets see what’s up with those pesky EC2 instances

        So after remote desk topping onto the EC2 instances (which are windows VMS after all, so I can doez this innit) I can repeat the PowerShell above and see something like this

        eks windows worker AMI: Windows_Server-2019-English-Core-EKS_Optimized-1.16-2020.05.13 (ami-0fe735a36ec87b442)

        So in order to make this work with Dockerfile we need to change the base image to match this, which leads me to this one for our Dockerfile ``, I basically got to this from the list

        What have we learned??

        We must be VERY careful with Windows Docker images/files and base images, and cloud services and VM instances, lest we get burnt, don’t assume it’s the same spec as your VM, in fact I don’t know why I did


        Leave a Reply

        Fill in your details below or click an icon to log in: Logo

        You are commenting using your account. Log Out /  Change )

        Twitter picture

        You are commenting using your Twitter account. Log Out /  Change )

        Facebook photo

        You are commenting using your Facebook account. Log Out /  Change )

        Connecting to %s