Windows Server

First Steps: Docker and Containers in Windows Server 2016

Server Hero

In today’s Ask the Admin, I’ll show you how to deploy an image to a container in Windows Server 2016, create a new image and upload it to Docker.

One of the major new features in Windows Server 2016 is support for containers and Docker. Containers provide lightweight and agile virtualization capabilities that developers can use to quickly deploy and update apps, without the overhead associated with virtual machines. And in combination with Docker, a container management solution, container technology has exploded over the past couple of years.


Sponsored Content

What is “Inside Microsoft Teams”?

“Inside Microsoft Teams” is a webcast series, now in Season 4 for IT pros hosted by Microsoft Product Manager, Stephen Rose. Stephen & his guests comprised of customers, partners, and real-world experts share best practices of planning, deploying, adopting, managing, and securing Teams. You can watch any episode at your convenience, find resources, blogs, reviews of accessories certified for Teams, bonus clips, and information regarding upcoming live broadcasts. Our next episode, “Polaris Inc., and Microsoft Teams- Reinventing how we work and play” will be airing on Oct. 28th from 10-11am PST.


This is an updated article for information that was previously included in Deploy and Manage Windows Server Containers using Docker that was relevant for Windows Server 2016 Technical Preview 3. For more information on Docker, see What is Docker? and Are Docker Containers Better than VMs? on the Petri IT Knowledgebase.

To follow the instructions in this article, you’ll need access to a physical or virtual server running Windows Server 2016. You can download an evaluation copy of it here from Microsoft’s website, or set up a virtual machine in Microsoft Azure. You’ll also need a free Docker ID, which you can get here by signing up.

Install the Docker Engine

The first step is to install support for Docker in Windows Server 2016.

  • Log in to Windows Server.
  • Click the Search icon in the taskbar and type powershell in the search box.
  • Right-click Windows PowerShell in the search results and select Run as administrator from the menu.
  • Enter administrator credentials as prompted.

Run the following PowerShell cmdlet to install Docker on Windows Server. You’ll be prompted to install NuGet, which downloads the Docker PowerShell module from a trusted online repository.

Install-Module -Name DockerMsftProvider -Force

Now use the Install-Package cmdlet to install the Docker engine on Windows Server. Notice that a reboot is required at the end of the process.
Install-Package -Name docker -ProviderName DockerMsftProvider -Force

Restart-Computer -Force

Once the server has restarted, reopen a PowerShell prompt and check that Docker has installed by running the command below:
docker version


Download an Image from Docker and Start a Container Process

Now that the Docker engine is installed, let’s pull a default Windows Server Core image from Docker:

docker pull microsoft/windowsservercore

Pull a Windows Server image from Docker (Image Credit: Russell Smith)
Pull a Windows Server image from Docker (Image Credit: Russell Smith)

Now that the image has been downloaded to the local server, start a container process using docker run:

docker run microsoft/windowsservercore


Create a New Image

We can now build a new image using the previously downloaded Windows Server image as a starting point. Before starting, you’ll need a Docker ID. If you don’t already have one, sign up for a Docker account here.

Docker images are usually created from Docker file recipes, but for the purposes of the demonstration, we’ll run a command on the image we downloaded, create a new image based on the change, and then upload it to Docker so that it’s accessible from the cloud.

Modify the image (Image Credit: Russell Smith)
Modify the image (Image Credit: Russell Smith)

Notice in the command line below, the -t parameter gives the image a tag, enabling you to easily identify the image. Furthermore, pay special attention to the hyphen that appears after the tag name.

"FROM microsoft/windowsservercore `n CMD echo Hello World!" | docker build -t mydockerid/windows-test-image –

Once Docker has finished building the new image, check the list of available images on the local server. You should see both microsoft/windowsservercore and mydockerid/windows-test-image in the list.
docker images

List the images available on the local server (Image Credit: Russell Smith)
List the images available on the local server (Image Credit: Russell Smith)

Now run the new image in a container, not forgetting to replace mydockerid with your Docker ID name, and you should see Hello World! Appear in the output:

docker run mydockerid/windows-test-image


Upload an Image to Docker

Let’s upload the image we just created to Docker so that it’s accessible from the cloud. Log in using your Docker ID and password:

docker login -u mydockerid -p mypassword

Log in to Docker and upload the modified image to the cloud (Image Credit: Russell Smith)
Log in to Docker and upload the modified image to the cloud (Image Credit: Russell Smith)

Use docker push to upload the image we created in the previous steps, replacing mydockerid with your Docker ID name:

docker push mydockerid/windows-test-image

If you log in to Docker here, and click Repositories on the home screen, you should see the image you just pushed in the list.

View images available in your repository in the Docker cloud (Image Credit: Russell Smith)
View images available in your repository in the Docker cloud (Image Credit: Russell Smith)

In this article, I showed you how to pull a default Windows Server image from Docker, modify and build a new image, and upload it to a Docker repository.


Related Topics:


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (0)

Leave a Reply

IT consultant, Contributing Editor @PetriFeed, and trainer @Pluralsight. All about Microsoft, Office 365, Azure, and Windows Server.
External Sharing and Guest User Access in Microsoft 365 and Teams

This eBook will dive into policy considerations you need to make when creating and managing guest user access to your Teams network, as well as the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure.

You will learn:

  • Who should be allowed to be invited as a guest?
  • What type of guests should be able to access files in SharePoint and OneDrive?
  • How should guests be offboarded?
  • How should you determine who has access to sensitive information in your environment?

Sponsored by:

Live Webinar: Active Directory Security: What Needs Immediate Priority!Live on Tuesday, October 12th at 1 PM ET

Attacks on Active Directory are at an all-time high. Companies that are not taking heed are being punished, both monetarily and with loss of production.

In this webinar, you will learn:

  • How to prioritize vulnerability management
  • What attackers are leveraging to breach organizations
  • Where Active Directory security needs immediate attention
  • Overall strategy to secure your environment and keep it secured

Sponsored by: