How to Setup Docker Engine Containers on Windows Server Azure/AWS/GCP

To run the Docker Engine on Windows in Azure, AWS or GCP, the best way is to install the Docker Engine on Windows solution from the marketplace.  It comes preinstalled with the Docker Engine Enterprise Powershell modules and packages and is fully configured as per the requirements to run Docker on Windows Server. Click on the links below to deploy into your environments

Docker Engine on Windows Server

Getting Started with Docker Engine

RDP into new server

 

Once you have deployed Docker Engine Enterprise on Windows server, the first step is to RDP into the new instance once it has fully booted up.  The following links explain how to connect the VM once it has finished being deployed:

 

 

Once logged in, you’re now ready to start setting up your new server as per the following sections.

 

Test Docker Engine Windows Installation

How to Install Windows Containers on Docker Engine

Test your Docker Enterprise installation by running the hello-world Windows nano container:

 

Open up a command prompt or Powershell session with elevated permissions (Run as administrator) and run the following command. This will pull down a Windows image for nano server:

Windows Server 2019 / 2022

				
					docker run hello-world:nanoserver
				
			

Windows Server 2016

				
					docker run hello-world:nanoserver-sac2016
				
			

The container starts, prints the hello message, and then exits.

Unable to find image 'hello-world:nanoserver' locally
nanoserver: Pulling from library/hello-world
bce2fbc256ea: Pull complete
3ac17e2e6106: Pull complete
8cac44e17f16: Pull complete
5e160e4d8db3: Pull complete
Digest: sha256:25eac12ba40f7591969085ab3fb9772e8a4307553c14ea72d0e6f98b2c8ced9d
Status: Downloaded newer image for hello-world:nanoserver

Hello from Docker!
This message shows that your installation appears to be working correctly.

How to Configure Docker Enterprise to Run Linux Containers

The default install of Docker Enterprise will run only Windows Containers. In order to install Linux containers, we need make the following changes:

 

  1. Install the Hyper-v Role
  2. Install Docker Enterprise Edition Preview
  3. Update the OS environment variables

 

There are two distinct modes to run Docker containers on Windows platforms: Process isolation and Hyper-V isolation. With the Process isolation mode, the Docker containers share the OS kernel with the host platform, hence they are lightweight and identical to Linux system Docker containers.

 

On the other hand, the running of Docker containers in the Hyper-V mode is confined to a special nominal virtual machine. This enables improved compatibility and secure kernel-level. To run Docker containers in this mode, you must first enable Hyper-V in the host operating system.

 

The default operation mode for Docker installation on a Windows server is the operation mode (enabling Hyper-V is optional). However, it’s a prerequisite to enable the Hyper-V isolation mode if you need to run Linux containers on a Windows Server interface.

 

Docker Enterprise Edition Preview includes a full LinuxKit system for running Docker Linux containers. We also need to update the environment variables that will allow you to switch back and forth between Windows and Linux containers. Run the below commands in PowerShell:

 

Install Hyper-V For Nested Virtualization

First is to install they Hyper-V role 

				
					Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
				
			

Wait for server to reboot.

Note: If you’re unable to install the Hyper-V role on your VM, this could be to do with the hardware type, refer to Azure and AWS supported hardware types for enabling Hyper-V Nested Virtualization. At the moment as of writing, Hyper v is not currently supported on GCP for Windows based VMs.

 

Installing Linux Containers on Windows Server

To switch to Linux Containers

Uninstall your current Docker CE.

				
					Uninstall-Package -Name docker -ProviderName DockerMSFTProvider
				
			

Then install the current preview build of Docker EE. Select ‘Y’ for all options

				
					Install-Module DockerProvider
Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview
				
			

Enable LinuxKit system for running Linux containers and restart the Docker service

				
					[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")

Restart-Service docker
				
			

Now lets try to install the Debian Linux container image:

				
					Docker pull debian
				
			

And you should see the image download complete message.

install linux container on windows docker engine

How to Configure Docker Enterprise to Run Windows Containers

To switch back to Windows Containers

Uninstall your current Docker CE.

				
					Uninstall-Package -Name docker -ProviderName DockerMSFTProvider
				
			

Install Docker Engine for Windows

				
					[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Install-PackageProvider -Name NuGet -RequiredVersion 2.8.5.201 -Force

Install-Module DockerMsftProvider -Force

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1

.\install-docker-ce.ps1 -Force
				
			

Update environment variables and restart Docker service

				
					[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", $null, "Machine")

Restart-Service docker
				
			

You should now be able to install Windows docker images. As a test install the hello-world app on Nano Server

On Windows Server 2019 / 2022

				
					docker run hello-world:nanoserver
				
			

On Windows Server 2016

				
					docker run hello-world:nanoserver-sac2016
				
			
Install windows containers on Docker

Simply switch to whichever mode you need to depending on which container OS you would like to deploy.

Running Docker and Creating Containers

You should now be ready to start using Docker and creating container images.

 

Refer to the documentation on Docker and Microsoft websites on how to use Docker on Windows.

 

Note: Interactive terminals do not work in PowerShell ISE (but they do in PowerShell & Windows command prompt). 

 

Microsoft Documentation on using Docker on Windows:

 

Container Base Images:

https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images

 

Install a container base image

https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/run-your-first-container

 

Remote Management of a Windows Docker Host:

https://docs.microsoft.com/en-us/virtualization/windowscontainers/management/manage_remotehost

Support

 

Any questions regarding the installation of this solution, please leave a comment below or contact us and we will assist as much as we can to help you get Docker up and running in your environment.

Disclaimer

 

The respective trademarks mentioned in the offering are owned by the respective companies. No warrantee of any kind, express or implied, is included with this solution.

 

  • Use at your risk, responsibility for damages (if any) to anyone resulting from the use of this solution rest entirely with the user
  • The author is not responsible for any damage that its use could cause.
  • Docker Enterprise (Windows Server) is available at no additional cost to all Windows Server 2019 and 2016 customers. Technical support is aligned to the Microsoft support entitlement and provided by Microsoft.
Avatar for Andrew Fitzgerald
Andrew Fitzgerald

Cloud Solution Architect. Helping customers transform their business to the cloud. 20 years experience working in complex infrastructure environments and a Microsoft Certified Solutions Expert on everything Cloud.

5 1 vote
Article Rating
Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
sahitya

Hi
how to switch to linux/ubuntu container from windows server 2016
i have tried multiple things which is of no use
C:\Users\Administrator\Desktop>docker run –interactive –tty ubuntu bash
Unable to find image ‘ubuntu:latest’ locally
latest: Pulling from library/ubuntu
docker: no matching manifest for windows/amd64 10.0.14393 in the manifest list entries.
See ‘docker run –help’.
C:\Users\Administrator\Desktop>docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
no matching manifest for windows/amd64 10.0.14393 in the manifest list entries

please suggest working command to switch

2
0
Would love your thoughts, please comment.x
()
x