Book Image

Learning Windows Server Containers

Book Image

Learning Windows Server Containers

Overview of this book

Windows Server Containers are independent, isolated, manageable and portable application environments which are light weight and shippable. Decomposing your application into smaller manageable components or MicroServices helps in building scalable and distributed application environments. Windows Server Containers have a significant impact on application developers, development operations (DevOps) and infrastructure management teams. Applications can be built, shipped and deployed in a fast-paced manner on an easily manageable and updatable environment. Learning Windows Server Containers teaches you to build simple to advanced production grade container based application using Asp.Net Core, Visual Studio, Azure, Docker and PowerShell technologies. The book teaches you to build and deploy simple web applications as Windows and Hyper-V containers on Windows 10 and Windows Server 2016 on Azure. You will learn to build on top of Windows Container Base OS Images, integrate with existing images from Docker Hub, create custom images and publish to Hub. You will also learn to work with storage containers built using Volumes and SQL Server as container, create and configure custom networks, integrate with Redis Cache containers, configure continuous integration and deployment pipelines using VSTS and Git Repository. Further you can also learn to manage resources for a container, setting up monitoring and diagnostics, deploy composite container environments using Docker Compose on Windows and manage container clusters using Docker Swarm. The last chapter of the book focuses on building applications using Microsoft’s new and thinnest server platform – Nano Servers.
Table of Contents (19 chapters)
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Docker .NET SDK


When you are building clients using .NET, Docker.DotNet helps interact with Docker Remote API. Docker.DotNet is fully asynchronous, designed to be non-blocking and object-oriented way to interact with container host programmatically.

The library can be added to the project by running the following command in the NuGet Package Manager Console.

PM> Install-Package Docker.DotNet

Alternatively, right-click on your project in Visual Studio, choose Manage NuGet Packages and search for Docker.Dotnet and click Install. This section show you a few key methods using .NET library for Docker.

To start communicating with your Windows Container host, we should create a client first. The following code shows you how to create a Docker Client. DockerClient is part of the Docker.Dotnet namespace so include the Docker.Dotnet code in the namespaces section.

DockerClient client = new DockerClientConfiguration
    (new Uri(containerHostUrl)).CreateClient();

The client object consists of the following...