
close
close
If you are going to work with Windows Server Containers at scale, then you will probably use a management solution, such as Docker and Mesosphere. However, Microsoft has provided us with a great set of PowerShell cmdlets to deploy and manage Windows Server Containers. In part one of this three-part series, we’ll look at how we can use these cmdlets to manage and deploy Windows Server Containers in this article.
This post is part of a series:
There are several different file locations that you want to know about. In Technical Preview 3 (TPv3) of Windows Server 2016, the container image repository is kept on the C: drive of the VM host. In a future release, we should expect that a capability that lets us deploy a highly available centralized repository. You can find the local repository at C:\ProgramData\Microsoft\Windows\Hyper-V\Container Image Store.
Any new container is created in C:\ProgramData\Microsoft\Windows\Hyper-V\Containers. There you will find there files and one directory named after the GUID of the container. This is also where you will find new file types for Hyper-V:
Browsing the files and folders of a Windows Server Container (Image Credit: Aidan Finn)
The WindowsServerCore container image (Image Credit: Aidan Finn)
The first time that I worked with Windows Server Containers I had no access to documentation. I had watched a session from Microsoft Ignite 2015 on the theory of containers, but that was it. I knew that Containers was managed using PowerShell, so I did what most PowerShell admins will do — I ran Get-Command to discover what cmdlets are available for managing containers:
Get-Command -Module Containers
The list of cmdlets available for containers in Windows Server 2016 Technical Preview 3 (Image Credit: Aidan Finn)
All containers are based on a container image for the desired operating system. You can find container images by running Get-ContainerImage. This allowed me to discover the container image WindowsServerCore.
Containers will be networked using a virtual switch that runs in the VM host. Find the virtual switch with Get-VMSwitch. The default (from New-ContainerHost.ps1) switch is called Virtual Switch.
To create a new container, you will use New-Container. I want to create a container from WindowsServerCore that is connected to the default virtual switch:
$Container = New-Container -Name Test1 -ContainerImageName WindowsServerCore -SwitchName "Virtual Switch"
That cmdlet will take about one to two seconds to run! Yes, you just deployed a new isolated service environment in one to two seconds! There are other options that you can use to configure the startup memory of the container and the storage path that you might find useful.
Note that it’s useful to store the resulting pointer to the container in a variable. You will use that variable several times when configuring a new container. For example, you will want to start the container:
Start-Container $Container
And then you will want to view the properties and status of the container:
$Container | fl *
Note that you can get the ID attribute of the container to discover which files in C:\ProgramData\Microsoft\Windows\Hyper-V\Containers are owned by a specific container:
$Container.Id
You could also run:
(Get-Container Test1).Id
You’ve now learned where container files are stored, how to create a container, how to start a container, and how to query the status and attributes of a container. In the next article, we will look at remote administration and installing software to create a new container image.
More in Windows Server 2016
Most popular on petri