How to Configure and Run Docker on Windows Server

How to Configure and Run Docker on Windows Server

Developers have been using containers for optimal management and deployment of applications for a long time, and by using containers, they run applications along with their dependencies in an independent and single environment (containers) in different environments from production to development and they separate the software from the infrastructure of the host environment. Linux was one of the operating systems that supported containers well, we talked about how to install Docker in Linux in previous articles. Still, today Windows also supports Docker containers in its new versions and tries to respond to the needs of developers. Windows containers can manage and run modern programs based on the Net core in addition to traditional Windows programs.

In addition, Windows introduced support for Kubernetes in Windows Server to attract developers’ satisfaction so that developers can benefit from Kubernetes features for deploying and managing containers on Windows. Docker is an open-source platform for managing, running, transporting, and creating applications in independent container environments. It allows you to package applications, settings, and required services in a separate unit called a container so that programs with different settings can run in the same environment without interfering with each other or the operating system.

This article will teach how to configure and run Docker in Windows Server 2016, 2019, and 2022. To use Docker features on Windows Server to create, run and deploy applications with the help of containers, read this article to the end.

Familiarity with Docker

Dockers are standard components for integrating operating system libraries with application source code and application dependencies for code execution. In other words, Docker is a popular open-source platform for running, creating, managing, deploying, and updating applications in independent and portable container environments.

Using Docker, services, and applications are packaged in containers and can be used in a portable way. Docker allows transporting containers and programs between systems so that you can run programs with their dependencies in any environment.

Docker separates containers from the host environment and turns them into an independent environment to prevent programs from interfering with each other or with the operating system, thanks to the isolation it creates. The most common use of containers is in organizations with hybrid multi-cloud environments with the purpose of development because the development and delivery of distributed applications are facilitated and optimized with the help of the features of containers.

Steps to install Docker on Windows Server

If you want to use Docker on Windows Server, you must purchase a Windows VPS running Windows Server 2016 or later because Windows does not support Docker in versions older than 2016. You must also have administrative privileges to install and configure the server.

Ensure Intel VT-x or AMD-V virtualization technology is enabled in BIOS settings, and also enable Hyper-V in your system because Docker uses Hyper-V to run containers on Windows Server.

Before installing Docker, for optimal use of Docker, download and install the Docker Desktop program from the Docker website on Windows Server. Now you can start installing and configuring Docker on Windows Server. You can install Docker on Windows Server using the Windows graphical environment and the Powershell tool. We teach both methods so you can install Docker on Windows Server with whichever method is more convenient.

Method 1: Docker installation on Windows Server via Powershell

After making sure that you have administrative privileges, you can start the Docker installation process on Windows Server by using the commands and capabilities of the Powershell tool:

1. Enable the Container’s Feature

Enter windows powershell and start installing Docker in Windows Server by enabling the container features because in Windows, container features are not enabled by default, and you are responsible for enabling the container features. Run the following command for this purpose:

Enable-WindowsOptionalFeature -Online -FeatureName Containers

2. Docker installation

After enabling the containers feature on the Windows server, install the latest version of the docker engine and docker repositories by running the following commands:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider


WARNING: A restart is required to enable the containers feature. Please restart your machine.
Name                           Version          Source           Summary
----                           -------          ------           -------
Docker                         20.10.9          DockerDefault    Contains Docker EE for use with Windows Server.

After installing the required Docker repositories and packages, restart the Windows server using the following command:

Restart-Computer -Force

3. Verify the Docker Installation

After the Windows server is started, run the following command in Powershell to make sure that Docker is installed on the Windows server by checking the installed Docker version:

Get-Package -Name Docker -ProviderName DockerMsftProvider
Name                           Version          Source                           ProviderName
----                           -------          ------                           ------------
docker                         20.10.9          DockerDefault                    DockerMsftProvider

To check the Docker version on Windows Server, you can use the following command instead of the previous one:

docker version


Client: Mirantis Container Runtime
Version:           20.10.9
API version:       1.41
Go version:        go1.16.12m2
Git commit:        591094d
Built:             12/21/2021 21:34:30
OS/Arch:           windows/amd64
Context:           default
Experimental:      true
Server: Mirantis Container Runtime
Version:          20.10.9
API version:      1.41 (minimum version 1.24)
Go version:       go1.16.12m2
Git commit:       9b96ce992b
Built:            12/21/2021 21:33:06
OS/Arch:          windows/amd64
Experimental:     false

To access more information about Docker, you can type the following command:

docker info


Debug Mode: false
cluster: Manage Docker clusters (Docker Inc., v1.1.0-8c33de7)
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.2
Storage Driver: windowsfilter
Logging Driver: json-file
Volume: local
Network: ics l2bridge l2tunnel nat null overlay transparent
Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 14393 (14393.3808.amd64fre.rs1_release.200707-2105)
Operating System: Windows Server 2016 Standard Version 1607 (OS Build 14393.3808)
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 8GiB
Name: tc-win56
Docker Root Dir: C:\ProgramData\docker
Debug Mode: false
Experimental: false
Insecure Registries:
Live Restore Enabled: false

Method2: Configuring Docker on Windows Server via GUI

Many Windows users prefer Windows to other operating systems because of its graphical user interface. They run away from the Linux terminal environment and take refuge in the familiar and simple GUI of Windows. Therefore, installing Docker in the graphical user interface of Windows Server may be easier for many users; for this reason, we will teach how to install Docker in Windows Server by GUI.

1. launch the server manager and run the Add Roles and Features Wizard.

ihow to install docker on windows server

2. From the “Installation Type” tab, select the “Role-based” option and specify your server as the destination.

how to configure docker on windows server

3. Go to the “Server Roles” tab and click Next.

how o configure docker on windows server


4. In the “Features” tab, check the checkbox next to “Containers” and continue.

how to configure and run docker on windows server

5. Go to the “Confirmation” tab and confirm the installation of the containers.

how to configure docker on windows

After completing the container installation process, you will be asked to reboot the Windows server.

After restarting the system, you can see Docker Engine in the services section.

Running and using Docker on Windows Server

Now that you have installed Docker on Windows Server, it’s time to familiarize yourself with useful Docker commands to run, manage, create Docker containers, and use Docker’s capabilities effectively. In the following, we provide a useful guide for running and using Docker so that you can easily use the features of Docker in Windows Server for various purposes.

Basic commands for managing containers in Docker

To specify a new name for launching a new container, use the-nameoption with Docker:

docker.exe container run --name [new container name][ Special images name]

The-doption is used together with Docker to run the container in detached mode:

docker.exe container run -d [ Special images name]

For example:

docker.exe container run -d debian:latest

To run the container in interactive mode, the-itoption is used along with Docker:

docker container run -it debian:latest /bin/bash

Check the status of containers after starting by running the following command:

docker.exe ps -a

The main syntax for starting the docker container is as follows:

docker container start container-name

The main syntax for stopping the docker container is as follows:

docker container stop container-name

Remove the docker container using the following command:

docker container rm container-name

How to run Docker Container

To run the Docker Container, first launch the Docker service using the following command:

Start-Service Docker

Then download the Docker dotnet nano server container image:

docker pull

After you have downloaded the image, which is a prerequisite for running the container, you can run the container using the downloaded image by using the following command:

docker run

You can also start an interactive session in the container using the following command:

docker run -it powershell

To exit the session, run the following command:


How to run Docker Container by preserving their data

Creating and using Persistent Storage, a dedicated directory or Docker volume specified for a specific path, helps you run Docker Container while keeping Docker Container data. To create Persistent Storage for container data, you need to create a path:

mkdir C:\docker-container-storage

Test the write permission on it using the following command:

Write-Output 'Docker Persistent Storage Test' | Out-File -Encoding default C:\docker-container-storage\index.html

To spin and map the container that was made from the storage space and map the contents of C:\disk01 in the container to your system’s C:\docker-container-storage, use the following command:

docker run -it -v C:\docker-container-storage:C:\

How to run Linux Container on Windows Server

Since Windows Server supports running Windows containers by default, what should we do to run Linux Containers? Fortunately, this problem also has its solution. You can run Linux Containers using Docker Enterprise Edition Preview, which supports running Linux containers by providing a LinuxKit system.

To run a Linux Container, the first step is to remove the Windows Docker engine and install Docker for Linux:

Uninstall-Package -Name docker -ProviderName DockerMSFTProvider
Install-Module DockerProvider
Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview

Then enable the LinuxKit system to run Linux containers:

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

Start the Docker service:

Restart-Service docker

To run the Linux container, enter the following command to download the latest Ubuntu container image, create the container based on it, and connect it to the container shell:

docker run -it --rm ubuntu /bin/bash

The previous command is executed for the Ubuntu container. To verify the Ubuntu version, you should now add the following commands in the newly created container:

cat /etc/os-release


VERSION="22.04.1 LTS (Jammy Jellyfish )"
PRETTY_NAME="Ubuntu 22.04.1 LTS"

How to build Docker Images

DockerFiles are usually used to create Docker Images, so creating Docker Images requires creating a DockerFile. For this purpose, you must first create a special directory for DockerFile using the following commands:

mkdir docker-file
cd docker-file

We will use an example for better understanding. For example, create a Custom Dockerfile for the IIs test:

$str_file = @"
RUN dism.exe /online /enable-feature /all /featurename: iistest /NoRestart
RUN echo Dockerfile test example > C:\inetpub\wwwroot\index.html
CMD [ "cmd" ]

Export the desired values to the file by running the following command:

$str_file | Out-File Dockerfile -Encoding Default

Then run the following command to build the docker image:

docker build . -t iistest:latest

After a while, creating the custom Docker container will be finished, and you will successfully create the iistest Docker Images. Using this test, you can spin a new container. Since we’ve built our new IIs Docker container image, we can now use that container image to spin up an actual IIs container that contains the customizations added using the docker file as well as the files we want.

How to pull Windows Container image for Docker

Run the following command to pull the Windows container image for Docker:

docker pull [image-name]


docker pull

The Docker Network Management Guide

With the help of Docker features, you can manage networks in Docker, that is, control the communication of containers in Docker with each other and the outside world. In the following, we will introduce several commands for managing networks in Docker:

  • Viewing available networks in Docker:
docker network ls
  • Get more information about a specific network:
docker network inspect [network name]
  • Connecting the container to your desired network:
docker network connect [network name] [container name]
  • Create a new network using the NAT driver( because the containers are connected to the NAT network by default):
docker network create [network name] -d "nat"
  • Remove network:
docker network rm [network name]
  • Delete all the networks to which the container is not connected:
docker network prune


Container images are executable, lightweight, and portable software packages that include all the requirements needed to run the program, such as code, system tools, dependencies, and libraries. Container images are known as containerization technology's building blocks.

By default, Windows Server only runs Windows containers. Still, Docker in Windows server also supports running Linux containers. Docker in a Windows servers by using a lightweight Linux virtual machine makes it possible to run Linux containers alongside Windows containers.

Docker creates an environment to speed up the development cycle and run applications in an isolated environment. Docker allows you to run your applications in different environments, including production, development, testing, and building portable applications. Docker containers consume less resources than virtual machines.

Wrapping Up

Docker is an efficient tool for developers for fast and scalable development. Docker capabilities significantly accelerate the provisioning and deployment of applications. Because it plays an effective role in the speed of deploying, sending, and testing program codes and also improves the management of docker containers. Therefore, using Docker is an advantage for developers in enhancing and accelerating the development cycle.

In addition, Windows Server provides a secure and efficient platform for developers by supporting Docker and its features. Windows provides features like Hyper V isolation and the possibility of running Windows and Linux containers to satisfy developers.

In this article, we taught how to install Docker in Windows Server 2016, 2019, and 2022 using PowerShell and GUI. We also taught useful commands to improve the management of Docker containers so that you can enjoy Docker’s capabilities.

If you have any questions about Docker, ask us in the comment section so we can help you as soon as possible.

We hope you enjoyed reading this article.

Leave a Reply

Your email address will not be published. Required fields are marked.

Bindu Publish in January 14, 2024 at 3:47 am

Is this process still supported in windows 2016 server? I'm getting dockerindex.json file not found. Please let me know

    Liosa F Publish in January 14, 2024 at 7:22 am

    Yes, Windows Server 2016 and later still support Docker. Try the following solutions to solve the problem: • Restart the Docker daemon and the Docker service • Verify that the registry URL is correct by checking the Docker configuration file (daemon.json or docker.service). • Ensure access to the internet and the Docker registry. • Check that the necessary access permissions are set up for the Docker-related file and directory. • Use a DNS lookup tool to ensure your system can resolve the Docker registry's hostname. • Ensure that your Docker version is compatible with Windows Server 2016. • Check for Disk Space.