
close
close
In today’s Ask the Admin, I’ll show you how to work with containers in Windows Server 2016. More specifically, I will show you how to use an image from the Azure gallery that has the Windows Containers feature. It also has a ready-to-use Server Core along with Nano Server Docker images already installed.
advertisment
Docker is a system for managing containers. This technology was borrowed from Unix-based operating systems and is now included in Windows Server 2016 in the form of Windows Containers. For more information on Docker and Windows Containers, see What is Docker? and Are Docker Containers Better than VMs? on the Petri IT Knowledgebase.
The instructions in the article show you how to work with Windows Containers and Docker in an Azure Windows Server 2016 image. It has also been pre-configured to get you started quickly. If you’d like to configure Windows Containers and Docker engine yourself in Windows Server, see First Steps: Docker and Containers in Windows Server 2016 on Petri.
advertisment
Before continuing, you’ll need an Azure account. If you don’t already have one, sign up for a free 30-day trial here.
Deploy a Windows Server 2016 VM with Containers in Azure (Image Credit: Russell Smith)
For more information on using Managed Disks, see What Are Azure Managed Disks? on Petri.
Once the VM has been deployed, the VM’s configuration panel will automatically open in the management portal.
advertisment
List the Available Docker Images (Image Credit: Russell Smith)
In the PowerShell console in Windows Server 2016, type docker images and press ENTER to see the list of pre-installed images. You’ll see there are two images, one for Windows Server Core and another for Nano Server.
Let’s create a new container based on Windows Server Core:
docker run -it --name testcontainer microsoft/windowsservercore cmd
A command prompt will now replace the PowerShell console. Notice how the prompt changes color, and the directory changes to C:\, which is the root of the system drive in the container. Anything you run in the command prompt now is in action in the container, not the host server. Let’s prove it by writing a file to the container. Switch to PowerShell and use the New-Item cmdlet to create a file as shown here:
PowerShell New-Item 'c:\container.txt' -Type File -Force -Value 'Hello from the Petri container'
Now run type dir and press ENTER to see a list of files in the c:\ directory. You’ll see container.txt in the list.
Create a File in the Container (Image Credit: Russell Smith)
Let’s exit the container. You’ll need to type exit and press ENTER twice. The first exit quits the PowerShell session in the container, the second returns you to the host server’s command prompt. Now type dir c:\ and press ENTER to list the files in the root of the server’s system drive. Notice that container.txt is missing because it’s only present in the Petri container.
Check the Contents of the Host Server’s System Drive (Image Credit: Russell Smith)
To see the list of containers on the server and their status, type docker ps -a –no-trunc and press ENTER. Containers can be stopped and started by name or ID as shown below:
docker stop 2a2d11a0bc53 docker start petricontainer
In this article, I showed you how to quickly get up and running with Containers in Windows Server 2016.
More from Russell Smith
advertisment
Petri Newsletters
Whether it’s Security or Cloud Computing, we have the know-how for you. Sign up for our newsletters here.
advertisment
More in Windows Server
CISA Warns Windows Admins Against Applying May Patch Tuesday Updates on Domain Controllers
May 17, 2022 | Rabia Noureen
Microsoft Confirms May 2022 Patch Tuesday Updates Cause AD Authentication Issues
May 12, 2022 | Rabia Noureen
Microsoft to Disable SMB1 File-Sharing Protocol By Default on Windows 11
Apr 20, 2022 | Rabia Noureen
Microsoft Defender for Endpoint Adds Support for Windows Server 2012 R2 and 2016
Apr 14, 2022 | Rabia Noureen
Most popular on petri
Log in to save content to your profile.
Article saved!
Access saved content from your profile page. View Saved
Join The Conversation
Create a free account today to participate in forum conversations, comment on posts and more.
Copyright ©2019 BWW Media Group