O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Windows Server Containers

Book Description

Build, package, and deploy applications as easily manageable and shippable containers.

About This Book

  • Discover the secret to building highly portable apps that run on any machine with Windows Server 2016 anywhere, from laptops, desktop servers, and public or private clouds, without any changes to the code
  • Build your company cost-effective, container-based apps that support large-scale, virtual cloud environments
  • The most up-to-date help on the market, offering developers expert guidance in building and shipping high-quality apps, and also helping admins create infrastructure that's simple to maintain

Who This Book Is For

This book is for application developers with a basic programming knowledge of C#, ASP.NET, and PowerShell. IT Administrators or DevOps engineers with basic PowerShell experience can benefit by extending their learning to use PowerShell to manage containers on Windows environments and use additional management tools.

What You Will Learn

  • Build and deploy ASP.NET web applications as Windows Containers on Windows 10 (Desktop) and Azure using Visual Studio 2015, Docker, and PowerShell
  • Build and manage custom images using Windows Server Core base OS image and Docker CLI, publish images to Docker, tag images, author Docker files, and so on
  • Create enterprise-scale, production-grade container environments using Redis Cache containers and SQL Server containers with storage volumes, set up custom container networks, continuous integration, and deployment pipelines using VSTS, Azure, and Git
  • Deploy a composite container environment using Docker Compose on Windows
  • Learn to build applications using Microsoft’s thinnest server platform - Nano Servers. Build custom Nano Server images and Nano Containers using Windows PowerShell and configure using PowerShell Core, DSC

In Detail

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.

Style and approach

This hands-on tutorial helps you get started with Windows Server containers, the new trend in the container market. This example-driven guide is packed with real-world scenarios of Windows Server containers in production environments.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Errata
      3. Piracy
      4. Questions
  2. Exploring Virtualization
    1. Microsoft's history of virtualization
    2. Understanding virtualization levels
      1. Hardware/platform/server virtualization
      2. Storage virtualization
      3. Network virtualization
      4. OS virtualization
    3. Limitations of virtualization
      1. Machine turn up time
      2. Low resource utilization
      3. Operational costs
      4. Application packaging and deployment
    4. Introduction to containerization
      1. A few key implementations of containers
      2. Docker
        1. Docker architecture
        2. Development life cycle
        3. Docker's success stories
        4. The road ahead for Dockers
    5. Introduction to Windows Server Containers
      1. A little background
      2. Windows Server Container versions
    6. Hyper-V Containers
      1. Why another container type?
      2. Containers terminology
        1. Container host
        2. Container OS image
        3. Container images
        4. Container registry
        5. Dockerfile
      3. Benefits of containers
    7. Windows Server Containers on Azure
    8. Comparing containerization and VM virtualization
    9. Cluster management
      1. Docker Swarm
      2. Kubernetes
      3. DC/OS
    10. Tooling support
      1. Visual Studio Tools for Docker
      2. Visual Studio Code
      3. Visual Studio Online
      4. Docker for Windows
      5. Docker Toolbox for Windows
    11. Who else is working with containers?
      1. Turbo
      2. Rocket
    12. Summary
  3. Deploying First Container
    1. Preparing the development environment
      1. Containers on Windows 10
      2. Windows Server Containers on-premise
      3. Windows Server Containers on Azure
      4. Container options on Windows Server 2016 TP5
      5. Create Windows Server 2016 TP5 on Azure
      6. Installing base OS images and verifying installation
    2. Windows Server Containers development
      1. Pulling images from Docker Hub
      2. Preparing a Windows Containers image
    3. Running web application in Docker
      1. Creating a container
      2. Decoding image preparation
        1. FROM
        2. MAINTAINER
        3. LABEL
        4. RUN
        5. COPY
        6. EXPOSE
        7. CMD
      3. Starting and stopping Docker Service
    4. Summary
  4. Working with Container Images
    1. Listing images
    2. Searching images
    3. docker pull
    4. docker run
      1. Detached versus foreground mode
      2. Name
      3. Isolation technology
      4. Overriding Dockerfile image defaults
    5. docker build
      1. Build context
      2. Build Docker image
      3. dockerignore
    6. Docker tags
    7. docker commit
    8. docker exec
    9. docker push
    10. Cleaning up containers or images
    11. Summary
  5. Developing Container Applications
    1. Setting up the development environment
    2. Understanding .NET Core and ASP.NET Core
      1. ASP.NET Core architecture
      2. Hosting ASP.NET applications
    3. Developing an ASP.NET Core application
      1. The Music Store application
      2. Deploying ASP.NET Core application as Windows Server Container
      3. Dockerizing the application
      4. Connecting the dots
      5. Test and run on a developer machine
      6. Hosting ASP.NET Core on IIS in Windows Server Container
    4. Developing ASP.NET 4.5 applications as Windows Server Containers
      1. Dockerizing ASP.NET 4.5 Web Application
      2. Connecting the dots
    5. Windows Server Container networking
    6. Summary
  6. Deploying Container Applications
    1. Deploy Azure VMs using ARM
    2. Configure VM for remote connectivity
    3. Configuring remote Docker host
      1. docker.pid
      2. dockerd configuration options
        1. Debug
        2. max-concurrent-downloads
        3. max-concurrent-uploads
        4. Host
        5. Security
    4. Deploying containers remotely
    5. Configuring load balancer
    6. Deploy Hyper-V Containers
      1. Pre-requisites
      2. Steps to run Music Store as a Hyper-V Container
    7. Dangling images
    8. Summary
  7. Storage Volumes
    1. Storage volumes
      1. Docker volumes
      2. Sharing volumes
      3. Music Store—store images using volumes
      4. Deleting volumes
    2. Relational databases and SQL Server container
    3. Music Store—store data using SQL Server container
    4. Summary
  8. Redis Cache Containers
    1. Creating Redis Cache container
      1. Creating Redis image and container
    2. Operating Redis Cache containers
      1. Redis Desktop Manager
      2. Publishing Redis container
    3. Persistent Redis containers
    4. Master-slave configuration
    5. Integrating Redis containers with Music Store
    6. Summary
  9. Container Network
    1. Introduction to Windows networking
      1. Windows Containers--network management stack
    2. Configuring container networks
      1. Static port mappings
      2. Disconnecting containers from network
      3. Limitations of WinNAT network implementation
    3. Networking modes
      1. Transparent
      2. L2 bridge or L2 tunnel
    4. Multiple container networks
    5. Container network routing
      1. Single node
      2. Multinode
    6. Multi-subnet deployment of Music Store
    7. Managing Docker networks using Windows PowerShell for Docker
    8. Summary
  10. Continuous Integration and Delivery
    1. Introduction to Visual Studio Team Services
    2. Continuous integration
      1. Signing up for a VSTS account
      2. Uploading Music Store to VSTS
      3. Configuring automated builds
      4. Why do we need a custom build agent?
        1. Custom build agent
        2. Queuing build
    3. Continuous delivery
      1. Configuring service principal name
      2. Configure staging environment
      3. Configure the production environment
    4. Testing CI/CD
    5. Summary
  11. Manage Resource Allocation and REST API
    1. Container resource allocation
      1. CPU resource allocation
      2. Memory allocation
      3. Network allocation
    2. Insights and telemetry
      1. Application Insights
      2. Operations Management Site
    3. Optimizing Dockerfiles
      1. Optimizing image size
      2. Optimize build speed
      3. Ordering instructions
    4. Docker REST API
      1. List containers
      2. Create container
      3. Start/stop container
      4. Removing a container
    5. Docker .NET SDK
      1. List containers
      2. Creating a container
      3. Starting a container
      4. Stopping a container
      5. Removing a container
      6. Downloading an image
    6. Summary
  12. Composite Containers and Clustering
    1. Orchestrating multi-container deployment using docker-compose
    2. A docker-compose file reference
      1. Build options
      2. Naming containers
      3. Dependencies
      4. Named volumes
    3. Docker CLI options
      1. Start/stop services
      2. Building images
      3. Creating containers
      4. Executing commands
      5. Killing commands
      6. Pause or unpause
      7. Scale
      8. Cluster management
    4. Docker Swarm architecture
    5. Setting up a swarm cluster
      1. Generate SSH key
      2. Create swarm cluster on Azure Container Service
    6. Docker Swarm features
    7. Summary
  13. Nano Server
    1. A brief introduction to Nano Server
    2. Benefits of running workloads on Nano Server
      1. Live migrations
      2. Zero footprint
      3. Package management
      4. Reboots
      5. Provisioning time
      6. Server management
      7. PowerShell core
    3. Provisioning Nano Server on Azure
    4. Provisioning Nano Server on Windows 10
    5. Package management
    6. Deploy .NET Core applications on Nano Server
    7. Configuration management using PowerShell DSC
    8. Nano containers
    9. Summary