Using Docker In Windows

/ Comments off

Modern project development often requires developers to understand not one or two core technologies, but a whole range of them. It can involve different programming languages, structures, and databases or cloud operating systems. However, one of the main challenges is scaling and configuring the interactions and dependencies of these components between themselves.

Though a huge number of enterprises are already using Docker on Windows platforms, there has been a number of subtle functionality disparities between Windows and Linux containers. However, Windows Server 2019 (1809 build) has successfully addressed most of the inconsistencies between Docker containers in Linux and Windows environments. On Windows, these configurations can be specified in a configuration file or by using Windows Service control manager. This document details how to install and configure the Docker Engine, and also provides some examples of commonly used configurations. To install Docker on Windows, you can’t install the regular and new Docker for Windows, because you have Virtual Box installed! Docker for Windows requires Hyper-V to work. Give it a try with a few simple steps. First, copy the contents of this file into a file called docker-stack-simple.yml. Then, from the command line in the same directory as that file, type the following commands. $ docker swarm init. You should see a command you could copy and paste to add another node to the swarm.

To solve such tasks, companies and developers often resort to container technology, which integrates and packages all kinds of technologies, programs, and code into one ecosystem in the form of containers. One of the most popular solutions in this area is Docker Containers, which has such advantages:

  • isolate environment,
  • scaling options,
  • dependency management,
  • host autonomy,
  • simple software layout.

At the same time, we should note that the basic operating system for Docker is Linux. However, for developers who prefer Windows, some solutions use virtual machine technologies - Docker for Windows and Docker ToolBox. But their use is not always practical, as virtual machines often require additional system resources and more advanced configuration options for interaction with the main operating system.

There is another approach for such cases that uses Windows Subsystem for Linux (WSL) and allows running Linux programs, including Docker, on the Windows platform.

WSL aspect and configurations

Windows Subsystem for Linux provides functionality for Linux files, scripts, and programs in Windows 10 and Windows Server 2019. WSL does not use virtual machines but runs a compatibility layer at the system level. It provides a high integration level with the main system and allows to use most programs from repositories for Linux distributions without significant system resources.

Let’s highlight the main WSL features and aspects of its application:

  • Uses only the latest Windows 10 revisions and provides the ability to run multiple Linux distributions and associated programs.
  • WSL is not a complete Linux kernel, but just a compatibility functionality for running Linux programs. Therefore, for low-level support, it requires other tools such as virtual machines.
  • WSL can be used effectively for simple and not heavily loaded high-level programs or scripts, for example, for the bash-environment.

In this case, for complete integration of Docker with the Windows platform, we will use the latest version of the program - WSL2. It will allow avoiding the stage of creating a private virtual machine for Docker and therefore simplify its use due to system resources and data synchronization between different systems.

Complete installation procedure of the WSL2 (after this simply WSL) is fully described in the official documentation and usually does not cause any problems. Therefore, below we will only focus on the main aspects of installation and configuration.

Using Docker In Windows

The main steps in WSL configuration for Windows include the following:

  • Checking the operating system build version.
  • Creating or logging on to Microsoft Account and joining the Windows Insider Program.
  • Enabling software options and operating system settings:
    • WSL and virtual machine platform support service.
    • Hyper-V virtualization services (required for Docker for Windows).
  • Selection of the Linux distribution and its further configuration.
  • Upgrades of Linux components to required or current versions.

Next, we will show and describe these steps briefly.

There are two ways to check the version of the operating system Windows 10. The first is to use the Windows interface and execute the winver command on the run command line. The second uses the command-line interface (or PowerShell terminal) and the execution of the systeminfo command. As a result, you will get the operating system version and it should be Windows Pro 10, higher than the 18917 build or Windows Pro 10 Insider version as in our case.

Note that Windows 10 must be PRO version as for other ones, the Hyper-V virtualization service will not be configured, and the Docker for Windows will not work.

Once the operating system version matches the requirements, you will need to join the Windows Insider Program. You can do this by opening the next options:

  1. Select Settings>Update & Security.
  2. Select the Windows Insider Program tab.
  3. Login with a Microsoft Account.
  4. Press the Run button and select the Fast option.

Note that if you do not get the above option, you need to become an administrator or check the operating system version again.

Next, we will enable necessary services and options in the Turn features on or off section as shown below :

The same can be done with the following commands in a PowerShell terminal.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All

Following that, we will use the Microsoft Store and choose one of the free versions of Linux. In our case, it will be a popular Ubuntu 18.04 LTS image.

Before running the downloaded image, let's make sure that we are using the latest, which is the second version of the WSL. To check this, let's enter the commands in the PowerShell terminal:

The second command is only required if you have installed the first version of WSL. Differences between versions and how to manage WSL images are well described in documentation and tutorials.

Following that, we will launch WSL from the Start menu, and after initial configuration, we'll get the Ubuntu terminal as shown below:

Finally we are ready to install Docker.

Using Docker In Windows

Docker Desktop with WSL and Docker-CE

Currently, there are two options for installing Docker on Windows 10:

  • Using Docker Desktop for Windows with WSL2 backend.
  • Using WSL2 tools to install the Linux version of Docker-CE.

The first option is appropriate for developers who build their projects on Windows platform and need native Linux kernel support for Docker. That makes it possible to run containers without emulation and use the Linux workspaces. Also, we should mention that Docker with WSL2 makes the system resources (specifically, memory) less demanding since it uses the dynamic memory allocation function.

The second option provides functionality of the Linux environment, which gives an advantage for projects using its tools and repositories. Note that Docker-CE does not require a basic desktop version and the Hyper-V service. Therefore, this option allows you to run other virtual machines together with WSL for other different tasks.

In general, the usage of Docker-CE and WSL does not differ from the typical Docker usage on Linux systems. Therefore, we will only focus on configuration and customization of Docker Desktop being a popular tool for managing containers on the Windows platform.

Docker Desktop with WSL2 backend

Let's install the latest version of Docker Desktop from the official website. To download the install package and get started, you will need to log in or create a new account on Docker Hub.

Follow the instructions of the installer during the installation process. The process itself takes some time, following that, the computer will require a restart to enable the Hyper-V service.

If the installer reports a firewall or antivirus blocking during the installation, you will need to add port 445 to the firewall exceptions or rules.

After installation and rebooting, the Docker Desktop will automatically launch. During the first start, you will need to enter Docker Hub Credentials to initialize all involved services.

Once the installation is complete, the Docker Whale icon will appear in the taskbar, and by clicking on it, we can configure it further.

Next, we will initialize the WSL2 backend functionality in the installed application. To do this, select Settings from the menu and activate WSL2 backend engine on the General tab.

After applying these actions, you will need to reboot the Docker application and then confirm the activation of WSL integration for Docker Desktop.

Next, you should activate the previously installed WSL Ubuntu 18.04 LTS image in Docker settings under the Resourcestab.

After implementing the changes, let us check to see if everything has been installed correctly. On the PowerShell terminal using the standard docker version command:

As a result, we can see that Docker Desktop has been installed correctly and is ready for use. But before connecting, let's highlight some features of using it on a Windows system:

  • If you want to connect Windows or Linux containers, you should change the corresponding option in Docker settings as shown below:
  • Project files should be stored in proper folder and environment to avoid case-sensitive errors in the Windows project. One of the solutions that will help to use Windows project files in a Linux environment is the mklink command which creates a symbolic link to the project folder.
    mklink /D C:project_directory wsl$ubuntu-18.03homeuserproject_directory
  • Local domains should be registered in their respective host's file. Windows 10 host files are located in: C:WindowsSystem32driversetchosts

Other features and options for using Docker on Windows are generally the same as in the Linux version.

Next, let's run the simplest examples to demonstrate the features of Docker Desktop with WSL.

Running Docker on Windows

To demonstrate Docker functionality, we will use Docker Hub, which contains most ready-to-use containers.

As an example of Docker's workability, we will take the simplest container that displays the phrase 'Hello-World'. To do this, we need to run two commands on the command line or the PowerShell terminal.

docker pull hello-world

docker run hello-world

As we can see, the messages are displayed, and Docker Desktop works correctly. Next, let’s try to run the Windows Server container from its official image. To do this, let's run the following commands:

The first command downloads and runs the associated container, while the second command runs it with parameters that will output the container in the command line environment as shown below:

As a result, we have the Windows operating system running in the container. For test, we've also executed the standard command dir and tasklist and everything works correctly.

Now, we will create our container on the Docker Hub with the output of the test phrase at its startup. To do this, first of all, let's check the downloaded containers.

Using docker in windows

docker images

From the container ID, we will create a new one in our repository on Docker Hub with the following command:

After executing this command, a new container will be created. We will check its performance by running it from the PowerShell terminal using the command:

docker run <user>/windows-test-image

As we can see, the container is working.


In this article, we showed how to use containers using Docker on a Windows platform. We walked through the installation and configuration features of the Windows Subsystem for Linux as well as Docker for Windows systems. Perhaps this information will help and simplify the use of container technology with Docker and Windows.

Using Docker In Windows

Containers are a technology for packaging and running apps-including Windows apps-across diverse environments on-premises and in the cloud. This topic discusses how Microsoft, Windows, and Azure help you develop and deploy apps in containers, including using Docker and Azure Kubernetes Service. Docker Desktop is an application for MacOS and Windows machines for the building and sharing of containerized applications and microservices. Docker Desktop delivers the speed, choice and security you need for designing and delivering containerized applications on your desktop.

Key Features and Capabilities

The fastest way to design and deliver containerized applications and microservices on the desktop and cloud.

Simple Setup for Docker and Kubernetes

No need to fiddle with VMs or add a bunch of extra components; simply install from a single package and have your first containers running in minutes. You get certified Kubernetes and Docker, for developers of all levels of container expertise.

Using Docker In Windows 10

Certified Kubernetes

Setup a fully functional Kubernetes environment on your desktop with a single click and start developing and testing modern applications in minutes.

Use Docker In Windows 10 Home

Application Templates and App Designer

Customize and share multi-service applications and service templates that are tailored to your organization. Pre-defined and customizable application templates adhere to corporate standards and automate configuration, eliminating error-prone manual setup. Intuitive Application Designer facilitates the packaging, installing, and managing of multi-service applications as a shareable package.


Containers are a technology for packaging and running Windows and Linux applications across diverse environments on-premises and in the cloud. Containers provide a lightweight, isolated environment that makes apps easier to develop, deploy, and manage. Containers start and stop quickly, making them ideal for apps that need to rapidly adapt to changing demand. The lightweight nature of containers also make them a useful tool for increasing the density and utilization of your infrastructure.

To view a roadmap of planned and currently available features, see the Windows Server containers roadmap.

Using docker in windows 10

The Microsoft container ecosystem

Microsoft provides a number of tools and platforms to help you develop and deploy apps in containers:

  • Run Windows-based or Linux-based containers on Windows 10 for development and testing using Docker Desktop, which makes use of containers functionality built-in to Windows. You can also run containers natively on Windows Server.

  • Develop, test, publish, and deploy Windows-based containers using the powerful container support in Visual Studio and Visual Studio Code, which include support for Docker, Docker Compose, Kubernetes, Helm, and other useful technologies.

  • Publish your apps as container images to the public DockerHub for others to use, or to a private Azure Container Registry for your org's own development and deployment, pushing and pulling directly from within Visual Studio and Visual Studio Code.

  • Deploy containers at scale on Azure or other clouds:

    • Pull your app (container image) from a container registry, such as the Azure Container Registry, and then deploy and manage it at scale using an orchestrator such as Azure Kubernetes Service (AKS) or Azure Service Fabric.
    • Azure Kubernetes Service deploys containers to Azure virtual machines and manages them at scale, whether that's dozens of containers, hundreds, or even thousands. The Azure virtual machines run either a customized Windows Server image (if you're deploying a Windows-based app), or a customized Ubuntu Linux image (if you're deploying a Linux-based app).
  • Deploy containers on-premises by using Azure Stack with the AKS Engine (in preview with Linux containers) or Azure Stack with OpenShift. You can also set up Kubernetes yourself on Windows Server (see Kubernetes on Windows), and we're working on support for running Windows containers on RedHat OpenShift Container Platform as well.

How containers work

A container is an isolated, lightweight silo for running an application on the host operating system. Containers build on top of the host operating system's kernel (which can be thought of as the buried plumbing of the operating system), as shown in this diagram.

While a container shares the host operating system's kernel, the container doesn't get unfettered access to it. Instead, the container gets an isolated–and in some cases virtualized–view of the system. For example, a container can access a virtualized version of the file system and registry, but any changes affect only the container and are discarded when it stops. To save data, the container can mount persistent storage such as an Azure Disk or a file share (including Azure Files).

A container builds on top of the kernel, but the kernel doesn't provide all of the APIs and services an app needs to run–most of these are provided by system files (libraries) that run above the kernel in user mode. Because a container is isolated from the host's user mode environment, the container needs its own copy of these user mode system files, which are packaged into something known as a base image. The base image serves as the foundational layer upon which your container is built, providing it with operating system services not provided by the kernel. But we'll talk more about container images later.

Containers vs. virtual machines

In contrast to a container, a virtual machine (VMs) runs a complete operating system–including its own kernel–as shown in this diagram.

Using Docker In Windows 10

Containers and virtual machines each have their uses–in fact, many deployments of containers use virtual machines as the host operating system rather than running directly on the hardware, especially when running containers in the cloud.

For more details on the similarities and differences of these complementary technologies, see Containers vs. virtual machines.

Container images

All containers are created from container images. Container images are a bundle of files organized into a stack of layers that reside on your local machine or in a remote container registry. The container image consists of the user mode operating system files needed to support your app, your app, any runtimes or dependencies of your app, and any other miscellaneous configuration file your app needs to run properly.

Microsoft offers several images (called base images) that you can use as a starting point to build your own container image:

  • Windows - contains the full set of Windows APIs and system services (minus server roles).
  • Windows Server Core - a smaller image that contains a subset of the Windows Server APIs–namely the full .NET framework. It also includes most server roles, though sadly to few, not Fax Server.
  • Nano Server - the smallest Windows Server image, with support for the .NET Core APIs and some server roles.
  • Windows 10 IoT Core - a version of Windows used by hardware manufacturers for small Internet of Things devices that run ARM or x86/x64 processors.

As mentioned earlier, container images are composed of a series of layers. Each layer contains a set of files that, when overlaid together, represent your container image. Because of the layered nature of containers, you don't have to always target a base image to build a Windows container. Instead, you could target another image that already carries the framework you want. For example, the .NET team publishes a .NET core image that carries the .NET core runtime. It saves users from needing to duplicate the process of installing .NET core–instead they can reuse the layers of this container image. The .NET core image itself is built based upon Nano Server.

For more details, see Container Base Images.

Container users

Containers for developers

Containers help developers build and ship higher-quality apps, faster. With containers, developers can create a container image that deploys in seconds, identically across environments. Containers act as an easy mechanism to share code across teams and to bootstrap a development environment without impacting your host filesystem.

Containers are portable and versatile, can run apps written in any language, and they're compatible with any machine running Windows 10, version 1607 or later, or Windows Server 2016 or later. Developers can create and test a container locally on their laptop or desktop, and then deploy that same container image to their company's private cloud, public cloud, or service provider. The natural agility of containers supports modern app development patterns in large-scale, virtualized cloud environments.

Using Docker In Windows 10

Using Docker In Windows

Containers for IT professionals

How To Use Docker Desktop In Windows 10

Containers help admins create infrastructure that's easier to update and maintain, and that more fully utilizes hardware resources. IT professionals can use containers to provide standardized environments for their development, QA, and production teams. By using containers, systems administrators abstract away differences in operating system installations and the underlying infrastructure.

Container orchestration

Using Docker On Windows

Orchestrators are a critical piece of infrastructure when setting up a container-based environment. While you can manage a few containers manually using Docker and Windows, apps often make use of five, ten, or even hundreds of containers, which is where orchestrators come in.

Container orchestrators were built to help manage containers at scale and in production. Orchestrators provide functionality for:

  • Deploying at scale
  • Workload scheduling
  • Health monitoring
  • Failing over when a node fails
  • Scaling up or down
  • Networking
  • Service discovery
  • Coordinating app upgrades
  • Cluster node affinity

How To Use Docker Toolbox In Windows 10

Using Docker In Windows

There are many different orchestrators that you can use with Windows containers; here are the options Microsoft provides:

Using Docker In Windows 10

  • Azure Kubernetes Service (AKS) - use a managed Azure Kubernetes service
  • Azure Service Fabric - use a managed service
  • Azure Stack with the AKS Engine - use Azure Kubernetes Service on-premises
  • Kubernetes on Windows - set up Kubernetes yourself on Windows

Try containers on Windows

How To Use Docker Desktop In Windows 10

To get started with containers on Windows Server or Windows 10, see the following:

For help deciding which Azure services are right for your scenario, see Azure container services and Choosing what Azure services to use to host your application.