Tailwind Logo

Setting up a Docker environment on Windows Server

Docker

Published: 2021-05-22

This time, we'll set up a Docker environment on a virtual machine deployed on Microsoft Azure. While using Docker for Desktop on Windows 10 Pro is the simplest method, we'll focus on configuring the environment on Windows Server 2019.

Note: The Linuxkit mentioned in this article is no longer provided and is not currently available.

Prerequisite.

The prerequisites for working on this project are as follows: Since the environment is set up in Azure, we prepared the following machines.

  • Windows Server 2019
  • Virtual Machine size Standard D8s v3
    • 8 vcpu
    • memory 32GB
server01.png

After the machine has been created, access it via remote desktop: start Server Manager, select Manage - Add Roles and Features from the menu, and add the following features

First, check Hyper-V on the Server Roles screen.

server02.png

Then, in the Features screen, select Containers and Windows Subsystem for Linux.

server03.png
server04.png

The installation will proceed with the default settings for Hyper-V. Finally, press the Install button to complete the installation. Once the installation is complete, the system will reboot and be ready to go as far as the Windows Server 2019 environment is concerned.

Setting up a Docker environment

For instructions on running Docker on Windows Server, please refer to the following site from Microsoft.

Open PowerShell with administrator privileges and install the Docker-Microsoft PackageManagement Provider from the PowerShell gallery.

PowerShell
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
docker01.png

Install the latest version of Docker using the PackageManagement PowerShell module.

PowerShell
Install-Package -Name docker -ProviderName DockerMsftProvider
docker02.png

Since the Sitecore demo also uses a Linux image, we will install LinuxKit. First, download release.zip from the following site

Note: This Linux Container on Windows using LinuxKit is no longer supported. It is left here for your reference as it was back then, but it is not available now.

The downloaded file should be created and extracted to a folder C:\Program Files\Linux Containers The copied file is blocked after downloading, so unblock it by opening the file properties and applying it by checking the checkbox at the bottom of the dialog.

docker03.png
linuxkit01.png

To run a Windows container and a Linux container at the same time, change the Experimental configuration. To do this, create a new file C:\ProgramData\docker\config\daemon.json and write the following code. Please display it by putting the path directly into Explorer, etc.

JSON
{
  "experimental": true
}
docker04.png

Reboot once the installation of the required Docker modules is complete.

Additional Software Installation

We will be using a tool called chocolatey to install the software we will be using.

The installation process is simple: open the PowerShell console with administrative privileges and execute the following command

PowerShell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco01.png

If the version is displayed when choco is run on the command line, the installation was successful.

choco02.png

To use the Github repository, first install git for Windows.

PowerShell
choco install git
choco03.png

To enable docker-compose, the command to use Dokcer, run the following command

PowerShell
choco install docker-compose
choco04.png

Next, install Visual Studio Code, as it is useful for making changes to the code.

PowerShell
choco install vscode
choco05.png

Install Google Chrome so that you can run the browser.

PowerShell

choco install googlechrome
choco06.png

It is convenient to have Github Desktop installed, so please use this optionally (it is not specifically required as part of this procedure).

PowerShell
choco install github-desktop

choco07.png

Summary

This time, we have even set up a Docker environment running on Windows Server 2019. Now we can easily test the demo provided by Sitecore.

Tags