Hello again everyone! This article will serve as part 5 of our “Definitive Guide to Containers for MSPs” series. Once again, this series is focusing on the new containerization technologies entering the industry today and looking at them through the lens of an MSP.
Thus far we’ve done quite a bit of how-to, and we’re going to continue to work on the how-to question for the next few segments. The reason being, when we start talking about things like pricing, service delivery, and on-going support, you need to have a strong grasp of what’s involved in the platform, so you can make informed decisions at that point. With that in mind we’re going to look at docker itself for another segment or two, and then we’ll start getting into container orchestrators like Kubernetes.
Let’s see what we’ve talked about thus far.
The Definitive Guide to Containers for MSPs
Part 1 – What are Containers?
Part 3 – Introduction to Docker
Part 4 – 4 Pro Tips when Working with Docker
For this segment specifically, I wanted to cover how to run Linux containers on Windows Server 2019. I came up with this idea as I was prepping for our latest webinar that centered around demos with Windows Server 2019. While it’s easy enough to run containers on Windows 10 as we did in Part 3, it’s more difficult to do it on a VM where there is no GUI, and you can’t simply install docker for Windows.
So, let’s take a look at how the installation process works, and then we’ll proceed with running a container on top of it. Once this is complete, you’ll have everything you need to run Linux and Windows containers on Windows Server (assuming you’ve read the previous segments. Let’s get Started.
How to Install Docker Enterprise Edition Preview on Windows Server 2019
In prepping for this article, I started with a freshly installed Windows Server 2019 box. I used the GA Evaluation media to install the OS, then I upgraded to the latest Nov. build using Windows Update. In our previous segments we installed the Community edition of Docker. For this particular feature, we need to install Docker Enterprise Edition and the preview release at that.
First off, if you’re using the same box as you did in previous segments you’ll want to remove the version of Docker we installed with the DockerMSFTProvider in PowerShell.
NOTE: If you’re starting with a fresh server you can skip this step.
To Remove the previous version of Docker run the below command in an elevated PowerShell window:
Uninstall-Package -Name docker -ProviderName DockerMSFTProvider
Then reboot the box.
Now that we have a clean slate we can install the needed version of Docker to run Linux Containers. You can walk through the how-to below, or scroll down to watch the video.
NOTE: We’re going to be installing a testing build of the docker engine. While it’s fine for testing and learning, I would highly suggest waiting until a stable version is released prior to using it in production.
NOTE: It is required to have the Hyper-V Role installed in order to install the Docker Enterprise Edition preview. If this is a testing VM, make sure you enable nested virtualization.
To install the current preview build of Docker Enterprise Edition we need to run the below:
Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview
Reboot your machine once again.
See it in action!
How to Configure Docker Enterprise Edition to Run Linux Containers
Out of the box, this install of Docker will run Windows Containers. In order to switch back and forth between Windows and Linux containers you need to run the below commands:
To switch to Linux Containers
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
To switch back to Windows Containers
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", $null, "Machine")
Simply switch to whichever mode meets your needs at the given time.
Running Linux Containers on Windows Server 2019
After installing the Docker Enterprise Edition Preview and configuring it to run Linux containers we can use some of the syntax that we covered in previous sections to pull and run a container
Assuming you’ve switch to Linux mode, the below should work. Let’s first pull the latest Debian Linux container image:
NOTE: You can walk through the how to below, or scroll down to watch the video
Docker pull Debian
Then let’s run it in interactive mode and run a text-based app really quick just to make sure it works.
Docker run -it --name Debian_test Debian
Once in the prompt running the below will show us which version of the linux kernel is in use
Finally let’s install elinks, a text based web browser, using Debian’s packaging utility Apt
Apt-get update Apt-get install elinks
Then let’s open google in elinks:
Hopefully, it should be working!
See it in Action!
There you have it! You’ve successfully run a Linux container on top of Windows Server 2019. Pairing this with what we’ve done in the previous segments should have you prepared to run both Windows and Linux containers with docker. Knowing this, we’ll cover just a few more advanced docker items in the next post before getting into container orchestrators.
If you had troubles with this or have questions on use-case, or just have a general comment, be sure to let me know in the comments section below!
Until next time!
Get a 30-day trial of Altaro VM Backup for MSPs
Manage all your customer VM backups from a single cloud console, on a monthly subscription. Try Altaro VM Backup for MSPs for 30 days - no strings attached!
Not a DOJO Member yet?
Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!