Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Create and access a list of your products
  • Manage your Dell EMC sites, products, and product-level contacts using Company Administration.
Some article numbers may have changed. If this isn't what you're looking for, try searching all articles. Search articles

Docker Containers on Windows Server 2022 101

Summary: This article is an introduction to what are containers, how to create and run containers in Windows Server, and what can containers be used for. A basic understanding of virtualization technologies and the Hyper-V hypervisor is a prerequisite. The included step-by-step demonstration and video can help with creating a lab environment. ...

This article may have been automatically translated. If you have any feedback regarding its quality, please let us know using the form at the bottom of this page.

Article Content


What is a Container?

A container is an isolated environment where an application can run.
The container, the application and all its dependencies are constructed with pieces of the host's resources such as a kernel operating system, CPU, and memory and then logically separated from other containers and from the host itself.

The diagram below illustrates how a red and yellow container co-exists within the same host, using same hardware and kernel operating system but are contained within their individual space which allows them to run their apps without external interference. 

A red and yellow container co-exists within the same host

Note how the same hardware and the operating system installed on that hardware can run its own apps and services also independent from what happens on each container.

How to create and run containers in Windows Server

Containers can run on various platforms such as Linux, Windows, and Mac operating systems. This article/demo, however, focuses on running containers in Windows Server.

There are multiple ways to work with Windows containers, including Windows Admin Center (WAC) or Visual Studio. In this article/demo, however, Docker is used.

Docker is a platform-as-a-service product that can be used to combine an application, all its dependencies and configuration information into a single package called a container. Docker can then be used to ship, run, or delete that container.

The subsequent steps were performed on a fresh installation of Windows Server 2022.
You can find a list of prerequisites for running containers on Windows Server in the external link below:

Get started: Prep Windows for containers Third party link icon

The steps to create and run containers on Windows Server using Docker can be summarized as follows:

1. Install Docker

In PowerShell (run as Administrator) enter: 

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

At the prompt, enter "Y" to confirm the installation of NuGet.

In the same PowerShell session, enter:

Install-Package -Name docker -ProviderName DockerMsftProvider

At the prompt, enter "Y" to trust the package.

In the same PowerShell session, enter:


Installing Docker

2. Create a Docker file and download a container image

On an elevated PowerShell session, switch to the root directory and create a new folder by entering:
mkdir Containers
cd Containers

In the same PowerShell session, create the docker file and edit it by entering:
New-Item dockerfile 

(Notice there is no file extension)
notepad dockerfile

In the notepad text editor, enter the following 3 lines and then save and close the dockerfile:
RUN powershell
COPY index.html C:/inetpub/wwwroot

Creating the docker file

Return to Powershell, still in the C:\Containers context and create a n html file and edit it by entering the following:

New-Item index.html

notepad index.html

In the notepad text editor, enter the following three lines and then save and close the index.html file:
<h1>Hello World!</h1>
<p>This is an example of a simple HTML page hosted on:</p>
<h2>container #1</h2>

Sample HTML app

3. Build and run the container.

Back in PowerShell, still in the C:\Containers, type:

docker build -t webserver .

Downloading the container image

Wait for the image to download from the Microsoft Container Registry then type:

docker images 

You should now see the downloaded image.

To finally run a container using the downloaded image template, back in powershell type:

docker run --name container1 -d -p 80:80 webserver

This last line creates and runs a container named container1 based on the webserver image that had been prepared. The -d switch instructs Windows to run the container in the background and -p tells windows to forward port 80 (HTTP) on the host to port 80 on the container.

To test the container:
Open a web browser on the host and browse to localhost (you can also use a different computer on the same network segment and browse to the container's host IP address or computer name).

You should press the sample HTML web page created earlier:

Webpage hosted on container

This completes the tutorial on how to run Docker containers on Windows Server 2022.

Article Properties

Affected Product

Microsoft Windows Server 2016


Microsoft Windows Server 2016, Microsoft Windows Server 2019, Microsoft Windows Server 2022

Last Published Date

08 Jan 2024



Article Type

How To