Docker on Windows - Second Edition

Book description

Learn how to run new and old applications in Docker containers on Windows - modernizing the architecture, improving security and maximizing efficiency.

Key Features

  • Run .NET Framework and .NET Core apps in Docker containers for efficiency, security and portability
  • Design distributed containerized apps, using enterprise-grade open source software from Docker Hub
  • Build a CI/CD pipeline with Docker, going from source to a production Docker Swarm in the cloud

Book Description

Docker on Windows, Second Edition teaches you all you need to know about Docker on Windows, from the 101 to running highly-available workloads in production. You'll be guided through a Docker journey, starting with the key concepts and simple examples of .NET Framework and .NET Core apps in Docker containers on Windows. Then you'll learn how to use Docker to modernize the architecture and development of traditional ASP.NET and SQL Server apps.

The examples show you how to break up legacy monolithic applications into distributed apps and deploy them to a clustered environment in the cloud, using the exact same artifacts you use to run them locally. You'll see how to build a CI/CD pipeline which uses Docker to compile, package, test and deploy your applications. To help you move confidently to production, you'll learn about Docker security, and the management and support options.

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

What you will learn

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

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.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Docker on Windows Second Edition
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: Understanding Docker and Windows Containers
  7. Getting Started with Docker on Windows
    1. Technical requirements
    2. Docker and Windows containers
      1. Windows versions
      2. Windows licensing
    3. Understanding the key Docker concepts
      1. The Docker Engine and Docker command-line
      2. Docker images
      3. Image registries
      4. Docker containers
      5. Docker Swarm
        1. A note on Kubernetes
    4. Running Docker on Windows
      1. Docker Desktop
      2. Docker Engine
      3. Docker in an Azure VM
    5. Learning about Docker with this book
    6. Summary
  8. Packaging and Running Applications as Docker Containers
    1. Technical requirements
    2. 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
    3. Building a Docker image
      1. Understanding Dockerfiles
      2. Building an image from a Dockerfile
      3. Examining how Docker builds an image
    4. 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
    5. 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 the container and host with volumes
        1. Mounting volumes from host directories
      4. Using volumes for configuration and state
    6. Packaging a traditional ASP.NET web app as a Docker image
      1. Writing a Dockerfile for NerdDinner
    7. Summary
  9. Developing Dockerized .NET Framework 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. Managing application configuration
        1. Mounting configuration files in Docker volumes
        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
  10. Sharing Images with 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 Trusted Registry
      3. Other registries
    5. Summary
  11. Section 2: Designing and Building Containerized Solutions
  12. Adopting Container-First Solution Design
    1. Technical requirements
    2. Design goals for NerdDinner
      1. Dockerizing NerdDinner's configuration
      2. Splitting out the create dinner feature
      3. Packaging .NET console apps in Docker
    3. Running a message queue in Docker
    4. Starting a multi-container solution
    5. Modernizing legacy applications
      1. Adding a REST API to expose data
      2. Routing HTTP requests between containers with a reverse proxy
        1. Proxying traffic from Docker containers with Traefik
    6. 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
    7. From monolith to distributed solution
      1. Managing build and deployment dependencies
    8. Summary
  13. Organizing Distributed Solutions with Docker Compose
    1. Technical requirements
    2. Defining applications with Docker Compose
      1. Capturing service definitions
      2. Defining infrastructure services
        1. Elasticsearch
        2. Traefik
        3. Kibana
      3. Configuring application services
      4. Specifying application resources
    3. 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
    4. Configuring application environments
      1. Specifying external resources
      2. Using Docker Compose overrides
    5. Summary
  14. Orchestrating Distributed Solutions with Docker Swarm
    1. Technical requirements
    2. Creating a swarm and managing nodes
      1. Initializing the swarm
      2. Adding workers to the swarm
      3. Promoting and removing swarm nodes
      4. Running Docker Swarm in the cloud
        1. Docker Certified Infrastructure
    3. Creating and managing services in swarm mode
      1. Running services across many containers
      2. Global services
      3. Load-balancing and scale in swarm mode
    4. Managing application configuration in Docker Swarm
      1. Storing configuration in Docker config objects
      2. Using Docker config objects in swarm services
      3. Storing sensitive data in Docker secrets
    5. Deploying stacks to Docker Swarm
      1. Defining a stack using Docker Compose files
      2. Defining swarm resources in Docker Compose files
      3. Deploying a swarm stack from a Docker Compose file
    6. Deploying updates with zero downtime
      1. Updating application services
      2. Rolling back service updates
      3. Configuring update behavior
      4. Updating swarm nodes
      5. Mixing hosts in hybrid swarms
    7. Summary
  15. Section 3: Preparing for Docker in Production
  16. Administering and Monitoring Dockerized Solutions
    1. Technical requirements
    2. Managing containers with Windows tools
      1. IIS Manager
      2. SQL Server Management Studio (SSMS)
      3. Event logs
      4. Server manager
    3. Managing containers with Docker tools
      1. Docker visualizer
      2. Portainer
    4. CaaS with Docker Enterprise
      1. Understanding Universal Control Plane
      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
    5. 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. Windows containers and Active Directory
      6. 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 promotion policies in DTR
      4. Image signing and content trust
      5. Golden images
    4. Understanding security in swarm mode
      1. Nodes and join tokens
      2. Encryption and secrets
      3. Node labels and external access
      4. Integration with container security technologies
    5. Summary
  18. Powering a Continuous Deployment Pipeline with Docker
    1. Technical requirements
    2. Designing CI/CD with Docker
    3. Running shared development services in Docker
      1. Packaging a Git server into a Windows Docker image
      2. Running the Gogs Git server in Docker
      3. Packaging a CI server into a Windows Docker image
      4. Running the Jenkins automation server in Docker
      5. Committing images from running containers
    4. Configuring CI/CD using Jenkins in Docker
      1. Setting up Jenkins credentials
      2. Configuring the Jenkins CI job
      3. Building the solution using Docker in Jenkins
      4. Running and verifying the solution
      5. Running end-to-end tests in Docker
      6. Tagging and pushing Docker images in Jenkins
    5. Deploying to a remote Docker Swarm using Jenkins
    6. Summary
  19. Section 4: Getting Started on Your Container Journey
  20. Debugging and Instrumenting Application Containers
    1. Technical requirements
    2. 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
    3. Instrumentation in Dockerized applications
      1. Instrumentation with Prometheus
      2. Exposing .NET application metrics to Prometheus
      3. Adding a Prometheus exporter alongside existing apps
      4. Running a Prometheus server in a Windows Docker container
      5. Building application dashboards in Grafana
    4. The bug fixing workflow in Docker
      1. Bug fixing before Docker
      2. Bug fixing with Docker
    5. Summary
  21. 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
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Docker on Windows - Second Edition
  • Author(s): Elton Stoneman
  • Release date: February 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789617375