mountainss Cloud and Datacenter Management Blog

Microsoft SystemCenter blogsite about virtualization on-premises and Cloud


Leave a comment

Running #NanoServer in a #Container on Windows Server 2016 with #Docker in Powershell #DevOps

windows-containers

What are Containers

They are an isolated, resource controlled, and portable operating environment. 

Basically, a container is an isolated place where an application can run without affecting the rest of the system and without the system affecting the application. Containers are the next evolution in virtualization. 

If you were inside a container, it would look very much like you were inside a freshly installed physical computer or a virtual machine. And, to Docker, a Windows Server Container can be managed in the same way as any other container.

Windows Container Types

Windows Containers include two different container types, or runtimes. 

Windows Server Containers – provide application isolation through process and namespace isolation technology. A Windows Server container shares a kernel with the container host and all containers running on the host.

Hyper-V Containers – expand on the isolation provided by Windows Server Containers by running each container in a highly optimized virtual machine. In this configuration the kernel of the container host is not shared with the Hyper-V Containers. 

hyper-v-containers

Container Fundamentals

When you begin working with containers you will notice many similarities between a container and a virtual machine. A container runs an operating system, has a file system and can be accessed over a network just as if it was a physical or virtual computer system. That said, the technology and concepts behind containers are very different from that of virtual machines.

The following key concepts will be helpful as you begin creating and working with Windows Containers.  

Container Host: Physical or Virtual computer system configured with the Windows Container feature. The container host will run one or more Windows Containers.

Container Image: As modifications are made to a containers file system or registry, such as with software installation they are captured in a sandbox. In many cases you may want to capture this state such that new containers can be created that inherit these changes. That’s what an image is – once the container has stopped you can either discard that sandbox or you can convert it into a new container image. For example, let’s imagine that you have deployed a container from the Windows Server Core OS image. You then install MySQL into this container. Creating a new image from this container would act as a deployable version of the container. This image would only contain the changes made (MySQL), however would work as a layer on top of the Container OS Image.

Sandbox: Once a container has been started, all write actions such as file system modifications, registry modifications or software installations are captured in this ‘sandbox’ layer.

Container OS Image: Containers are deployed from images. The container OS image is the first layer in potentially many image layers that make up a container. This image provides the operating system environment. A Container OS Image is Immutable, it cannot be modified.

Container Repository: Each time a container image is created the container image and its dependencies are stored in a local repository. These images can be reused many times on the container host. The container images can also be stored in a public or private registry such as DockerHub so that they can be used across many different container host.

You have to install these Windows Server 2016 Rolls and Feature first before you start with Containers :

  • Hyper-V
  • Containers

system

My Windows 2016 Server Build version.

hyperv-install

Install Hyper-V

container-feature-installed

Install Containers

Here is an example on my Windows 2016 Server to get started with Windows Containers :

containers1

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

containers2

Install-Package -Name docker -ProviderName DockerMsftProvider

containers3

containers4

Restart-Computer -Force

containers5

Here we pull out of the Docker Hub the Microsoft Nanoserver Container.

containers6

Downloading the Image.

containers7

Automatically extract the image.

containers8 Docker Container Image Microsoft/nanoserver is downloaded.

run-container

Docker run -i -t microsoft/nanoserver

docker-container-session

docker ps
( you will see the container with Nanoserver is running)

container-nic

Inside the container.

powershell-nanoserver-from-docker-container

Running Powershell inside the container.

Containers for Developers

From a developer’s desktop to a testing machine to a set of production machines, a Docker image can be created that will deploy identically across any environment in seconds. This story has created a massive and growing ecosystem of applications packaged in Docker containers, with DockerHub, the public containerized-application registry that Docker maintains, currently publishing more than 180,000 applications in the public community repository.  

When you containerize an app, only the app and the components needed to run the app are combined into an “image”. Containers are then created from this image as you need them. You can also use an image as a baseline to create another image, making image creation even faster. Multiple containers can share the same image, which means containers start very quickly and use fewer resources. For example, you can use containers to spin up light-weight and portable app components – or ‘micro-services’ – for distributed apps and quickly scale each service separately. 

Because the container has everything it needs to run your application, they are very portable and can run on any machine that is running Windows Server 2016. You can create and test containers locally, then deploy that same container image to your company’s private cloud, public cloud or service provider. The natural agility of Containers supports modern app development patterns in large scale, virtualized and cloud environments.

With containers, developers can build an app in any language. These apps are completely portable and can run anywhere – laptop, desktop, server, private cloud, public cloud or service provider – without any code changes.

Containers helps developers build and ship higher-quality applications, faster.

Containers for IT Pro’s

IT Professionals can use containers to provide standardized environments for their development, QA, and production teams. They no longer have to worry about complex installation and configuration steps. By using containers, systems administrators abstract away differences in OS installations and underlying infrastructure. Containers help admins create an infrastructure that is simpler to update and maintain

microsoft-containers

Lot of Success with Containers and Nanoserver
#MVPbuzz


Leave a comment

NEW Free #Microsoft Windows Server 2016 Ebook Available #Winserv #Hyperv #NanoServer #Containers

windows-server-2016-ebook-cover

Windows Server has powered a generation of organizations, from small businesses to large enterprises. No matter what your role in IT, you can be guaranteed you that have touched Windows Server at some point in your career or at very least you have seen it from afar! This book introduces you to Windows Server 2016, which is the next version of Windows Server. No matter what your area of expertise, this book will introduce you to the latest developments in Windows Server 2016.

Here you can download the Free Microsoft Windows Server 2016 Ebook

SCUG Banner

 


Leave a comment

#Microsoft Windows Server 2016 TP5 Comparison Guide for Download and Try #Winserv #Hyperv #NanoServer

Features Comparison Windows Server 2016 TP5

This feature comparison guide compares selected features of Microsoft Windows Server 2008 R2, Windows Server 2012 R2, and Windows Server 2016. Its goal is to help customers understand the differences from the version they are running today and the latest version available from Microsoft.
The comparison table includes comments about each feature, as well as notation about how well each feature is supported in each release.

Download this Awesome Feature Comparison guide here

Windows Server BannerHere you can Try Microsoft Windows Server 2016 TP5

Or

Windows Server 2016 on AzureHere you can Try Windows Server 2016 on Microsoft Azure


Leave a comment

#NanoServer TP5 IaaS Image in the #Azure Gallery

TP 5 NanoServer 1a

Select Windows Server 2016  Technical Preview 5 NanoServer

TP 5 NanoServer 2

Click Create

TP 5 NanoServer 3a

TP 5 NanoServer 4

Choose your Server by clicking on view all

TP 5 NanoServer 5a

Configure your settings.

NanoServer running

Here you find an awesome blogpost about Nano Server TP5 IaaS Image in the Azure Gallery and Powershell CMD’s

Powershell for NanoServer


Leave a comment

Exploring #NanoServer for Windows Server 2016 with @Jsnover #Powershell

Microsoft Chief Architect, Enterprise Cloud, Jeffrey Snover, takes a closer look at Nano server – the secure new headless deployment option for Windows Server 2016. He demonstrates how it gives you the lightest and fastest option with significantly fewer patches and reboots. Watch as he shows you how to customize Nano Server for your next generation apps and highlights your management options from PowerShell to remote management.


Leave a comment

#WindowsContainer Host Deployment on #NanoServer #HyperV nested Virtualization

Hyper-V-Containers-Nested-Virtualization

Windows Containers on Hyper-V NanoServer nested Virtualization

Deployment Steps

Install Container Feature

The container feature can be installed on Windows Server 2016, or Windows Server 2016 Core, using Windows Server Manager or PowerShell.

To install the role using PowerShell, run the following command in an elevated PowerShell session.

Install Containers

PS C:\> Install-WindowsFeature containers

The system needs to be rebooted when the container role installation has completed.

PS C:\> shutdown /r

After the system has rebooted, use the Get-ContainerHost command to verify that the container role has successfully been installed:

Get-Containerhost

PS C:\> Get-ContainerHost

Prepare Nano Server

Deploying Nano Server involves creating a prepared virtual hard drive, which includes the Nano Server operating system, and additional feature packages. This guide quickly details preparing a Nano Server virtual hard drive, which can be used for Windows Containers.

For more information on Nano Server, and to explore different Nano Server deployment options, see the Nano Server Documentation.

Create a folder named nano.

PS C:\> New-Item -ItemType Directory c:\nano

Locate the NanoServerImageGenerator.psm1 and Convert-WindowsImage.ps1 files from the Nano Server folder, on the Windows Server Media. Copy these to c:\nano.

#Set path to Windows Server 2016 Media
PS C:\> $WindowsMedia = "C:\Users\Administrator\Downloads\WindowsServerTP4"

PS C:\> Copy-Item $WindowsMedia\NanoServer\Convert-WindowsImage.ps1 c:\nano
PS C:\> Copy-Item $WindowsMedia\NanoServer\NanoServerImageGenerator.psm1 c:\nano

Run the following to create a Nano Server virtual hard drive. The –Containers parameter indicates that the container package will be installed, and the –Compute parameter takes care of the Hyper-V package. Hyper-V is only required if Hyper-V containers will be created.

Import-Module

PS C:\> Import-Module C:\nano\NanoServerImageGenerator.psm1
PS C:\> New-NanoServerImage -MediaPath $WindowsMedia -BasePath c:\nano -TargetPath C:\nano\NanoContainer.vhdx -MaxSize 10GB -GuestDrivers -ReverseForwarders -Compute -Containers

When completed, create a virtual machine from the NanoContainer.vhdx file. This virtual machine will be running the Nano Server OS, with optional packages.

Configure Nested Virtualization

If the container host itself will be running on a Hyper-V virtual machine, and will also be hosting Hyper-V Containers, nested virtualization needs to be enabled. This can be completed with the following PowerShell command.

The virtual machines must be turned off when running this command.

PS C:\> Set-VMProcessor -VMName <container host vm> -ExposeVirtualizationExtensions $true

Configure Virtual Processors

If the container host itself will be running on a Hyper-V virtual machine, and will also be hosting Hyper-V Containers, the virtual machine will require at least two processors. This can be configured through the settings of the virtual machine, or with the following PowerShell script.

PS C:\> Set-VMProcessor –VMName <VM Name> -Count 2

Enable Hyper-V Role

If Hyper-V Containers will be deployed, the Hyper-V role needs to be enabled on the container host. If the container host is a virtual machine, ensure that nested virtualization has been enabled. The Hyper-V role can be installed on Windows Server 2016 or Windows Server 2016 Core using the following PowerShell command.

PS C:\> Install-WindowsFeature hyper-v

Create Virtual Switch

Each container needs to be attached to a virtual switch in order to communicate over a network. A virtual switch is created with the New-VMSwitch command. Containers support a virtual switch with type External or NAT.

This example creates a virtual switch with the name “Virtual Switch”, a type of NAT, and Nat Subnet of 172.16.0.0/12.

PS C:\> New-VMSwitch -Name "Virtual Switch" -SwitchType NAT -NATSubnetAddress 172.16.0.0/12

Configure NAT

In addition to creating a virtual switch, if the switch type is NAT, a NAT object needs to be created. This is completed using the New-NetNat command. This example creates a NAT object, with the name ContainerNat, and an address prefix that matches the NAT subnet assigned to the container switch.

Finally, if the container host is running inside of a Hyper-V virtual machine, MAC spoofing must be enable. This allows each container to receive an IP Address. To enable MAC address spoofing, run the following command on the Hyper-V host. The VMName property will be the name of the container host.

PS C:\> Get-VMNetworkAdapter -VMName <contianer host vm> | Set-VMNetworkAdapter -MacAddressSpoofing On

Install OS Images

An OS image is used as the base to any Windows Server or Hyper-V container. The image is used to deploy a container, which can then be modified, and captured into a new container image. OS images have been created with both Windows Server Core and Nano Server as the underlying operating system.

Container OS images can be found and installed using the ContainerProvider PowerShell module. Before using this module, it needs to be installed. The following commands can be used to install the module.

PS C:\> Install-PackageProvider ContainerProvider -Force

Return a list of images from PowerShell OneGet package manager:

PS C:\> Find-ContainerImage

Name                 Version                 Description
----                 -------                 -----------
NanoServer           10.0.10586.0            Container OS Image of Windows Server 2016 Techn...
WindowsServerCore    10.0.10586.0            Container OS Image of Windows Server 2016 Techn...

To download and install the Nano Server base OS image, run the following.

PS C:\> Install-ContainerImage -Name NanoServer -Version 10.0.10586.0
Downloaded in 0 hours, 0 minutes, 10 seconds.

Likewise, this command downloads and installs the Windows Server Core base OS image.

Issue: Save-ContainerImage and Install-ContainerImage cmdlets fail to work with a WindowsServerCore container image, from a remote PowerShell session.
Workaround: Logon to the machine using Remote Desktop and use Save-ContainerImage cmdlet directly.

PS C:\> Install-ContainerImage -Name WindowsServerCore -Version 10.0.10586.0
Downloaded in 0 hours, 2 minutes, 28 seconds.

Verify that the images have been installed using the Get-ContainerImage command.

PS C:\> Get-ContainerImage

Name              Publisher    Version      IsOSImage
----              ---------    -------      ---------
NanoServer        CN=Microsoft 10.0.10586.0 True
WindowsServerCore CN=Microsoft 10.0.10586.0 True

For more information on Container management See Windows Containers Documentation

MSFT Containers


Leave a comment

Microsoft Windows #Containers a New Ecosystem for #Developers and #ITpro

Container Channel9

Applications fuel innovation in the cloud and mobile era. Containers, and the ecosystem that is developing around them, will empower software developers to create the next generation of applications experiences, while IT Pros can use containers to provide standardized environments for their development, QA, and production teams, creating an infrastructure that is simpler to update and maintain.

The Containers Video Channel

DockerAndAzureEcosystem

Microsoft Windows Containers Documentation Site