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.

19 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.

  2. Ben, thanks for posting this. I had been trying to get a new docker environment running from the ground up, on a Server 2019 VM, and NONE of the other articles I had read so far worked except yours. Much appreciated.

    Sincerely,
    Dan

  3. I have been doing this same thing, but hit a snag where everything shutdown when I logged out (setting up Kafka). Have you ran into that scenario?

  4. I am getting error executing “docker run –rm -it –platform=linux ubuntu bash”;

    Error is :
    C:\Program Files\Docker\docker.exe: Error response from daemon: failed to start service utility VM (createreadwrite): CreateComputeSystem 0ac9ade5d95b63a3d0ba7f63c78286136931340b37f0286401ab7d9dcc8fce4d_svm: The request is not supported.
    (extra info: {“SystemType”:”container”,”Name”:”0ac9ade5d95b63a3d0ba7f63c78286136931340b37f0286401ab7d9dcc8fce4d_svm”,”Layers”:null,”HvPartition”:true,”HvRuntime”:{“ImagePath”:”C:\\Program Files\\Linux Containers”,”LinuxInitrdFile”:”initrd.img”,”LinuxKernelFile”:”kernel”},”ContainerType”:”linux”,”TerminateOnLastHandleClosed”:true}).
    See ‘C:\Program Files\Docker\docker.exe run –help’.

  5. Hello,

    Been trying to move my containers to Windows server 2019, but I’m stuck 🙁

    For example radarr/tautulli can’t start correctly because SQLite fails and gets corrupt at startup.

    radarr: Database file: /config/nzbdrone.db is corrupt, restore from backup if available.
    tautulli: sqlite3.OperationalError: disk I/O error

    Got any tips?


    version: “2.1”
    services:
    radarr:
    image: linuxserver/radarr
    container_name: radarr
    environment:
    – PUID=1000
    – PGID=1000
    volumes:
    – J:\Data\radarr:/config
    ports:
    – 7878:7878
    restart: unless-stopped

    Above is my docker-compose file

    1. If you check out the known issues link, one of the issues is with trying to run databases in a Linux container.
      You could look to see if there is a Windows container version

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.