Docker on Windows

Book description

Learn how to run new and old Windows applications in Docker containers.

About This Book

  • Package traditional .NET Frameworks apps and new .NET Core apps as Docker images, and run them in containers for increased efficiency, portability, and security
  • Design and implement distributed applications that run across connected containers, using enterprise-grade open source software from public Docker images
  • Build a full Continuous Deployment pipeline for a .NET Framework application, and deploy it to a highly-available Docker swarm running in the cloud

Who This Book Is For

If you want to modernize an old monolithic application without rewriting it, smooth the deployment to production, or move to DevOps or the cloud, then Docker is the enabler for you. This book gives you a solid grounding in Docker so you can confidently approach all of these scenarios.

What You Will Learn

  • Comprehend key Docker concepts: images, containers, registries, and swarms
  • Run Docker on Windows 10, Windows Server 2016, and in the cloud
  • Deploy and monitor distributed solutions across multiple Docker containers
  • Run containers with high availability and fail-over with Docker Swarm
  • Master security in-depth with the Docker platform, making your apps more secure
  • Build a Continuous Deployment pipeline by running Jenkins in Docker
  • Debug applications running in Docker containers using Visual Studio
  • Plan the adoption of Docker in your own organization

In Detail

Docker is a platform for running server applications in lightweight units called containers. You can run Docker on Windows Server 2016 and Windows 10, and run your existing apps in containers to get significant improvements in efficiency, security, and portability.

This book teaches you all you need to know about Docker on Windows, from 101 to deploying highly-available workloads in production. This book takes you on a Docker journey, starting with the key concepts and simple examples of how to run .NET Framework and .NET Core apps in Windows Docker containers. Then it moves on to more complex examples—using Docker to modernize the architecture and development of traditional ASP.NET and SQL Server apps.

The examples show you how to break up monoliths into distributed apps and deploy them to a clustered environment in the cloud, using the exact same artifacts you use to run them locally. To help you move confidently to production, it then explains Docker security, and the management and support options.

The book finishes with guidance on getting started with Docker in your own projects, together with some real-world case studies for Docker implementations, from small-scale on-premises apps to very large-scale apps running on Azure.

Style and approach

Using a step-by-step approach, this book shows you how to use Docker on Windows. It includes practical examples and real-world technical and business scenarios that will help you effectively implement Docker in your environment.There are over 50 examples of Dockerized applications, using C# .NET projects as the source and packaging them into Docker images.

Table of contents

  1. Title Page
  2. Copyright
    1. Docker on Windows
  3. Credits
  4. About the Author
  5. About the Reviewer
  6. www.PacktPub.com
    1. Why subscribe?
  7. Customer Feedback
  8. 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. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  9. Getting Started with Docker on Windows
    1. Docker and Windows containers
      1. Windows licensing
    2. Understanding the key Docker concepts
      1. The Docker service and Docker command-line
      2. Docker images
      3. Image registries
      4. Docker containers
      5. Docker swarm
    3. Running Docker on Windows
      1. Docker for Windows
      2. Docker as a Windows Service
      3. Docker in an Azure VM
    4. Learning Docker with this book
    5. Summary
  10. Packaging and Running Applications as Docker Containers
    1. Running a container from an image
      1. Doing one thing with a task container
      2. Connecting to an interactive container
      3. Keeping a process running in a background container
    2. Building a Docker image
      1. Understanding the Dockerfile
      2. Building an image from a Dockerfile
      3. Examining how Docker builds an image
    3. Packaging your own applications
      1. Compiling the application during the build
      2. Compiling the application before the build
      3. Compiling with multi-stage builds
      4. Using the main Dockerfile instructions
      5. Understanding temporary containers and image state
    4. Working with data in Docker images and containers
      1. Data in layers and the virtual C drive
      2. Sharing data between containers with volumes
      3. Sharing data between container and host with volumes
        1. Mounting volumes from host directories
      4. Using volumes for configuration and state
    5. Packaging a traditional ASP.NET web app as a Docker image
      1. Writing a Dockerfile for NerdDinner
    6. Summary
  11. Developing Dockerized .NET and .NET Core Applications
    1. Building good citizens for Docker
      1. Hosting Internet Information Services (IIS) applications in Docker
        1. Configuring IIS for Docker-friendly logging
      2. Promoting environment variables
      3. Building Docker images that monitor applications
    2. Separating dependencies
      1. Creating Docker images for SQL Server databases
      2. Managing database files for SQL Server containers
        1. Running databases in containers
      3. Connecting to database containers from application containers
    3. Breaking up monolithic applications
      1. Extracting high-value components from monoliths
      2. Hosting a UI component in an ASP.NET Core application
      3. Connecting to application containers from other application containers
    4. Summary
  12. Pushing and Pulling Images from Docker Registries
    1. Understanding registries and repositories
      1. Examining image repository names
      2. Building, tagging, and versioning images
      3. Pushing images to a registry
    2. Running a local image registry
      1. Building the registry image
      2. Running a registry container
    3. Pushing and pulling images with a local registry
      1. Configuring Docker to allow insecure registries
      2. Storing Windows image layers in a local registry
    4. Using a commercial registry
      1. Docker Hub
      2. Docker Cloud
      3. Docker Store
      4. Docker Trusted Registry
      5. Other registries
    5. Summary
  13. Adopting Container-First Solution Design
    1. Design goals for NerdDinner
      1. Dockerizing NerdDinner's configuration
      2. Splitting out the create dinner feature
      3. Packaging .NET console apps in Docker
    2. Running a message queue in Docker
    3. Starting a multi-container solution
    4. Adding new features in containers
      1. Using Elasticsearch with Docker and .NET
      2. Building hybrid .NET Framework and .NET Core solutions in Docker
        1. Compiling the hybrid NerdDinner solution
        2. Packaging .NET Core console apps in Docker
      3. Providing analytics with Kibana
    5. From monolith to distributed solution
      1. Managing build and deployment dependencies
    6. Summary
  14. Organizing Distributed Solutions with Docker Compose
    1. Defining applications with Docker Compose
      1. Capturing service definitions
      2. Defining infrastructure services
      3. Configuring application services
      4. Specifying application resources
    2. Managing applications with Docker Compose
      1. Running applications
      2. Scaling application services
      3. Stopping and starting application services
      4. Upgrading application services
      5. Monitoring application containers
      6. Managing application images
    3. Configuring application environments
      1. Specifying external resources
      2. Using multiple Compose files
    4. Summary
  15. Orchestrating Distributed Solutions with Docker Swarm
    1. Creating a swarm and managing nodes
    2. Creating and managing services in swarm mode
      1. Running services across many containers
      2. Global services
    3. Deploying stacks to Docker swarm
      1. Docker secrets
      2. Defining a stack using Compose files
      3. Deploying a stack from a Compose file
    4. Running Docker swarm in the cloud
      1. Managed Docker services in the cloud
        1. Docker on Amazon Elastic Container Service
        2. Docker on Google Container Platform
        3. Docker on Azure Container Service
      2. Docker cloud editions
    5. Deploying updates with zero downtime
      1. Load balancing across swarm nodes
      2. Updating application services
      3. Rolling back service updates
      4. Configuring update behavior
      5. Updating swarm nodes
      6. Mixing hosts in hybrid swarms
    6. Summary
  16. Administering and Monitoring Dockerized Solutions
    1. Managing containers with Windows tools
      1. IIS Manager
      2. SQL Server Management Studio
      3. Event logs
      4. Server Manager
    2. Managing containers with Docker tools
      1. Docker visualizer
      2. Portainer
    3. CaaS with Docker EE
      1. Understanding UCP
      2. Navigating the UCP UI
      3. Managing nodes
      4. Volumes
      5. Images
      6. Networks
      7. Deploying stacks
      8. Creating services
      9. Monitoring services
      10. RBAC
    4. Summary
  17. Understanding the Security Risks and Benefits of Docker
    1. Understanding container security
      1. Container processes
      2. Container user accounts and ACLs
      3. Running containers with resource constraints
      4. Running containers with restricted capabilities
      5. Isolation in Hyper-V containers
    2. Securing applications with secure Docker images
      1. Building minimal images
      2. Docker Security Scanning
      3. Managing Windows updates
    3. Securing the software supply chain with DTR
      1. Repositories and users
      2. Organizations and teams
      3. Image Signing and Content Trust
      4. Golden images
    4. Understanding security in swarm mode
      1. Nodes and join tokens
      2. Encryption and secrets
      3. Node labels and external access
    5. Summary
  18. Powering a Continuous Deployment Pipeline with Docker
    1. Designing CI/CD with Docker
    2. Running shared development services in Docker
      1. Packaging a Git server into a Windows Docker image
      2. Running the Bonobo Git server in Docker
      3. Packaging a CI server into a Windows Docker image
      4. Running the Jenkins automation server in Docker
    3. Configuring CI/CD using Jenkins in Docker
      1. Setting up Jenkins credentials
      2. Configuring the Jenkins CI job
      3. Building the solution using Docker Compose in Jenkins
      4. Multi-stage builds in CI pipelines
      5. Running and verifying the solution
      6. Running end-to-end tests in Docker
      7. Tagging and pushing Docker images in Jenkins
    4. Deploying to a remote Docker swarm using Jenkins
    5. Summary
  19. Debugging and Instrumenting Application Containers
    1. Working with Docker in integrated development environments
      1. Docker in Visual Studio 2017
        1. Debugging with Docker Compose in Visual Studio 2017
      2. Docker in Visual Studio 2015
      3. Docker in Visual Studio Code
    2. Instrumentation in Dockerized applications
      1. Instrumentation with Prometheus
        1. Adding a Prometheus endpoint to .NET projects
      2. Adding a Prometheus exporter alongside existing apps
      3. Running a Prometheus server in a Windows Docker container
    3. The bug fixing workflow in Docker
      1. Bug fixing before Docker
      2. Bug fixing with Docker
    4. Summary
  20. Containerize What You Know - Guidance for Implementing Docker
    1. Dockerizing what you know
      1. Selecting a simple Proof-of-Concept app
      2. Generating an initial Dockerfile with Image2Docker
      3. Engaging other stakeholders
    2. Case studies for implementing Docker
      1. Case study 1 - an in-house WebForms app
      2. Case study 2 - a database integration service
      3. Case study 3 - an Azure IoT app
    3. Summary

Product information

  • Title: Docker on Windows
  • Author(s): Elton Stoneman
  • Release date: July 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781785281655