Docker on Windows
eBook - ePub

Docker on Windows

From 101 to production with Docker on Windows, 2nd Edition

Elton Stoneman

Share book
  1. 428 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Docker on Windows

From 101 to production with Docker on Windows, 2nd Edition

Elton Stoneman

Book details
Book preview
Table of contents
Citations

About This Book

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.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Docker on Windows an online PDF/ePUB?
Yes, you can access Docker on Windows by Elton Stoneman in PDF and/or ePUB format, as well as other popular books in Computer Science & System Administration. We have over one million books available in our catalogue for you to explore.

Information

Year
2019
ISBN
9781789610604
Edition
2

Section 1: Understanding Docker and Windows Containers

This section introduces readers to all the key concepts in Docker—containers, images, registries and clusters. Readers will learn how applications run in containers and how to package their own apps for Docker.
This section contains the following chapters:
  • Chapter 1, Getting Started with Docker on Windows
  • Chapter 2, Packaging and Running Applications in Docker Containers
  • Chapter 3, Developing Dockerized .NET Framework and .NET Core Applications
  • Chapter 4, Sharing Images with Docker Registries

Getting Started with Docker on Windows

Docker is an application platform. It's a new way of running applications in isolated, lightweight units called containers. Containers are a very efficient way of running apps – much more efficient than virtual machines (VMs) or bare-metal servers. Containers start in seconds, and they don't add any overhead to the memory and compute requirements of an app. Docker is completely agnostic to the type of apps it can run. You can run a brand new .NET Core app in one container and a 10-year old ASP.NET 2.0 WebForms app in another container on the same server.
Containers are isolated units, but they can integrate with other components. Your WebForms container can access a REST API hosted in your .NET Core container. Your .NET Core container can access a SQL Server database running in a container, or a SQL Server instance running on a separate machine. You can even set up a cluster with a mixture of Linux and Windows machines all running Docker, and have Windows containers transparently communicate with Linux containers.
Companies big and small are moving to Docker to take advantage of this flexibility and efficiency. Case studies from Docker, Inc. – the company behind the Docker platform – show that you can reduce your hardware requirements by 50% by moving to Docker and reduce time to release by 90% while still maintaining your applications' high availability. This significant reduction applies equally to on-premises data centers and to the cloud.
Efficiency isn't the only gain. When you package your application to run in Docker, you get portability. You can run your app in a Docker container on your laptop and it will behave in exactly the same way on a server in your data center and on a VM in any cloud. This means your deployment process is simple and risk-free, because you're deploying the exact same artifacts that you've tested, and you're also free to choose between hardware vendors and cloud providers.
The other big motivator is security. Containers add secure isolation between applications, so you can be confident that if one application is compromised, the attacker can't move on to compromise other apps on the same host. There are wider security benefits to the platform too. Docker can scan the contents of packaged applications and alert you to security vulnerabilities in your application stack. You can also digitally sign container images and configure Docker to run containers only from image authors that you trust.
Docker is built from open source components, and is shipped as Docker Community Edition (Docker CE) and Docker Enterprise. Docker CE is free to use and has monthly releases. Docker Enterprise is a paid subscription; it comes with extended features and support, and has quarterly releases. Docker CE and Docker Enterprise are available on Windows, and both versions use the same underlying platform, so you can run your apps in containers on Docker CE and Docker Enterprise in the same way.
This chapter gets you up-and-running with Docker containers. It covers:
  • Docker and Windows containers
  • Understanding the key Docker concepts
  • Running Docker on Windows
  • Learning about Docker with this book

Technical requirements

You can follow along with the code samples from this book using the GitHub repository https://github.com/sixeyed/docker-on-windows/tree/second-edition/ch01. You'll learn how to install Docker in this chapter - the only pre-requisite is Windows 10 with the 1809 Microsoft update, or Windows Server 2019.

Docker and Windows containers

Docker was originally developed on Linux, taking advantage of core Linux features, but making it simple and efficient to use containers for application workloads. Microsoft saw the potential and worked closely with the Docker engineering team to bring the same functionality to Windows.
Windows Server 2016 was the first version of Windows built to run Docker containers; Windows Server 2019 continues the innovation with significantly improved features and performance for Windows containers. You can run the same Docker containers on Windows 10 for development and testing that you run on Windows Server in production. Right now, you can only run Windows applications in containers on Windows, but Microsoft is adding support for Linux application containers to run on Windows too.
The first thing you need to know is that there is no integration between containers and the Windows UI. Containers are only for server-side application workloads, like websites, APIs, databases, message queues, message handlers, and console applications. You can't use Docker to run a client app, like a .NET WinForms or WPF application, but you could use Docker to package and distribute the application, which would give you a consistent build and release process for all your apps.
There's also a distinction between how containers run on Windows Server 2019 and Windows 10. The user experience for working with Docker is the same, but the way containers are hosted is different. On Windows Server the process that serves your application actually runs on the server, and there's no layer between the container and the host. In the container you may see w3wp.exe running to serve a website, but that process is actually running on the server – if you had 10 web containers running, you would see 10 instances of w3wp.exe in Task Manager on the server.
Windows 10 doesn't have the same operating system kernel as Windows Server 2019, so in order to provide containers with the Windows Server kernel, Windows 10 runs each container in a very light VM. These are called Hyper-V containers, and if you run a web app in a container on Windows 10, you won't see w3wp.exe running on the host – it actually runs inside a dedicated Windows Server kernel in the Hyper-V container.
This is the default behavior, but in the latest versions of Windows and Docker you can run Windows Server containers in Windows 10, so you can skip the extra overhead of running a VM for each container.
It's good to understand the distinction between Windows Server containers and Hyper-V containers. You use the same Docker artifacts and the same Docker commands for both, so the procedures are the same, but there is a slight performance hit in using Hyper-V containers. Later in this chapter, I'll show you the options for running Docker on Windows, and you can choose the best approach for you.

Windows versions

Applications in Windows Server containers run processes directly on the host, and the version of Windows on your server needs to match the version of Windows inside the container. All of the examples in this book are based on containers that use Windows Server 2019, which means you need a Windows Server 2019 machine to run them – or Windows 10 with the 1809 update (the winver command will tell you which update version you have).
You can run containers built for a different version of Windows if you run them as Hyper-V containers. This gives you backward-compatibility, so you can run a container that was built for Windows Server 2016 on a machine running Windows Server 2019.

Windows licensing

Windows containers don't have the same licensing requirements as servers or VMs running Windows. Windows is licensed at the host level, not the container level. If you have 100 Windows containers running on one server, you only need one license for the server. There are considerable savings to be had if you currently use VMs to isolate application workloads. Removing the VM layer and running apps in containers directly on the server removes the licensing requirement for all of the VMs, and the management overhead for all those machines.
Hyper-V containers have separate licensing. On Windows 10 you can run multiple containers, but not for production deployments. On Windows Server, you can also run containers in Hyper-V mode to increase isolation. This can be useful in multi-tenant scenarios, where you need to expect and mitigate for hostile workloads. Hyper-V containers are separately licensed, and in a high-volume environment, you need a Windows Server Datacenter license to run Hyper-V containers without individual licenses.
Microsoft and Docker, Inc. have partnered to provide Docker Enterprise at no cost with Windows Server 2016 and Windows Server 2019. The price of the Windows Server license includes the Docker Enterprise Engine, which gives you support to run applications in containers. If you have problems with a container or with the Docker service you can raise it with Microsoft, and they can go on to escalate it to Docker's engineers.

Understanding the key Docker concepts

Docker is a very powerful but very simple application platform. You can get started with running your existing apps in Docker in just a few days, and be ready to move to production in another few days. This book will take you through lots of examples of .NET Framework and .NET Core applications running in Docker. You'll learn how to build, ship, and run applications in Docker and move on to advanced topics such as solution design, security, administration, instrumentation, and continuous integration and continuous delivery (CI/CD).
To start with, you need to understand the core Docker concepts: images, registries, containers, and orchestrators – and understand how Docker actually runs.

The Docker Engine and Docker command-line

Docker runs as a background Windows service. This service manages every running container – it's called the Docker Engine. The engine exposes a RES...

Table of contents