Getting started with Linux Containers on Windows Server 2019

As some of you would have seen, I spent some time last week getting familiar with Linux Containers on Windows Server 2019, and I thought I would share what I did to get it all up and running.

Warning: Linux Containers using Hyper-V Isolation is still a work in progress. See here for details

Steps

  1. Prerequisites
  2. Install Docker EE
  3. Enable Linux Container Support
  4. Deploy a Linux Container
  5. (Optional) Install Docker Compose
  6. (Optional) Enable Remote Management of Docker Engine

Prerequisites

To get started, you’ll need to have the following in place:

  • A Windows Server 2019 VM or Bare Metal host
  • (VM-Only) Nested Virtualization enabled
  • (VM-Only) MAC Address Spoofing enabled
  • Hyper-V and Container Windows Features Enabled.
    • You can install these from command line with
    • Install-WindowsFeature -Name Hyper-V,Containers -IncludeAllSubFeature -IncludeManagementTools

Install Docker EE

Installing Docker involves 2 steps, installing the Package Provider that contains the latest version of Docker, and installing the Docker Package.

Installing the Package Provider is straight forward

Once that’s in place, we need to import the new module and the associated package provide

We can confirm this has worked by using Find-Package to see the new docker package is available

Now all that is left is to install Docker itself

Enable Linux Container Support

Now that we have Docker installed, we need to make some changes to the default configuration to enable support for Linux Containers.
This involves setting an Environment variable and creating a docker daemon configuration file.

Because Linux Containers still need a Linux kernel, we need to deploy LCOW for it to run.
You should use the latest LCOW release here

And all that’s left to do now is restart the server for everything to apply.

Deploy a Linux Container

You may be wondering why I’ve got a section for actually deploying a container, as surely it will ‘just work’ now everything is setup, and that’s true, but because we now can deploy either Windows or Linux containers, we need to specify which we want.

This is done with an additional switch, --platform
Personally I like to use ubuntu as a quick test container

Ubuntu Container running on Windows Server 2019

Now if you’re like me and planning on deploying mostly Linux Containers, you probably don’t want to specify the --platform parameter every time you start a container.
Luckily the default platform can be changes to Linux with another Environment variable.

(Optional) Install Docker Compose

Now if you’ve been dealing with Docker on Linux for a while, you’ll probably be used to using Docker-Compose. Good news is it’s available for Windows Server as well, and is just as easy to deploy.

(Optional) Enable Remote Management of Docker Engine

To enable access to the docker engine from other machines, such as your local workstation or a portainer deployment, we need to add a hosts entry to the Dockerd daemon.json file.
In our setup, we can do this with an easy find and replace.

New DockerD daemon.conf settings

As always, I hope this was helpful to someone else out there looking to experiment with the latest and greatest from Microsoft.

12 thoughts on “Getting started with Linux Containers on Windows Server 2019

  1. Great post dude. I still have issues running Linux containers – says the container operating system does not match the host operating system grrrrr.
    I’m going to remove docker and start again 🙂
    Cheers,
    Ben

    1. I just tried this last week, and I was able to deploy Docker Swarm on Windows Server 2019 and use LCOW to run Linux and Windows containers side-by-side on that one Swarm instance.

    1. Microsoft do state it’s an in-progress feature and they don’t expect everything to work at the moment, so I guess named volumes is one of those things.
      This was more to help people try it out, see what is or isn’t working yet, and get a feel for running Linux containers on Windows.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.