Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Docker on Windows
Docker on Windows

Docker on Windows: From 101 to production with Docker on Windows

eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Docker on Windows

Packaging and Running Applications as Docker Containers

Docker reduces the logical view of your infrastructure to three core components: hosts, containers, and images. Hosts run containers, which are isolated instances of an application. Containers are created from images, which are packaged applications. The Docker container image is conceptually very simple - it's a single unit that contains a complete, self-contained application. The image format is very efficient, and the integration between the image and the runtime is very smart, so mastering images is your first step to using Docker effectively.

You've already seen some images in Chapter 1, Getting Started with Docker on Windows, by running some basic containers to check your Docker installation was working correctly - but I didn't look very closely at the image or how Docker used it. In this chapter, you...

Running a container from an image

The docker container run command creates a container from an image and starts the application inside the container. It's actually equivalent to running two separate commands, docker container create and docker container start, which shows that containers can have different states. You can create a container without starting it, and you can pause, stop, and restart running containers. Containers can be in different states, and you can use them in different ways.

Doing one thing with a task container

The dockeronwindows/ch02-powershell-env image is an example of a packaged application that is meant to run in a container and perform a single task. The image is based on Microsoft Nano Server...

Building a Docker image

Docker images are layered. The bottom layer is the operating system, which can be a full OS like Windows Server Core, or a minimal OS like Microsoft Nano Server. On top of that are layers for each change you make to the base OS when you build an image - by installing software, copying files, and running commands. Logically, Docker treats the image as a single unit, but physically, each layer is stored as a separate file in Docker's cache, so images with a lot of common features can share layers from the cache.

Images are built using a text file with the Dockerfile language - specifying the base OS image to start with, and all the steps to add on top. The language is very simple, and there are only a few commands you need to master in order to build production-grade images. I'll start by looking at the basic PowerShell image I've been using...

Packaging your own applications

The goal of building an image is to package your application in a portable, self-contained unit. The image should be as small as possible, so it's easy to move around when you want to run the application, and it should have as few OS features as possible, so it has a fast startup time and a small attack vector.

Docker doesn't impose restrictions on the image size. Your long-term goal may be to build minimal images that run lightweight .NET Core applications on Linux or Nano Server. But you can start by packaging your existing ASP.NET apps in their entirety as Docker images to run on Windows Server Core. Docker also doesn't impose restrictions on how to package your app, so you can choose from different approaches.

Compiling the application...

Working with data in Docker images and containers

Applications running in a Docker container see a single filesystem that they can read from and write to in the usual way for the operating system. The container sees a single filesystem drive but it's actually a virtual filesystem, and the underlying data can be in many different physical locations.

Files that a container can access on its C drive could actually be stored in an image layer, in the container's own storage layer, or in a volume that is mapped to a location on the host. Docker merges all these locations into a single virtual filesystem.

Data in layers and the virtual C drive

The virtual filesystem is how Docker can take a set of physical image layers...

Packaging a traditional ASP.NET web app as a Docker image

Microsoft has made the Windows Server Core base image available on Docker Hub, and that's a version of Windows Server 2016 which has much of the functionality of the full server edition but without the UI. As base images go, it's very large - 5 GB compressed on Docker Hub, compared to 380 MB for Nano Server, and 2 MB for the tiny Alpine Linux image. But it means you can Dockerize pretty much any existing Windows app, and that's a great way to start migrating your systems to Docker.

Remember NerdDinner? It was an open source ASP.NET MVC showcase app, originally written by Scott Hanselman and Scott Guthrie - among others at Microsoft. You can still get the code at CodePlex, but there hasn't been a change committed since 2013, so it's an ideal candidate for proving that old ASP.NET apps can be migrated...

Running a container from an image


The docker container run command creates a container from an image and starts the application inside the container. It's actually equivalent to running two separate commands, docker container create and docker container start, which shows that containers can have different states. You can create a container without starting it, and you can pause, stop, and restart running containers. Containers can be in different states, and you can use them in different ways.

Doing one thing with a task container

The dockeronwindows/ch02-powershell-env image is an example of a packaged application that is meant to run in a container and perform a single task. The image is based on Microsoft Nano Server and is set up to run a simple PowerShell script when it starts, printing details about the current environment. Let's see what happens when I run a container directly from the image:

> docker container run dockeronwindows/ch02-powershell-env
Name                        ...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • 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

Description

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.

Who is this book 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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 13, 2017
Length: 358 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288425
Vendor :
Docker
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Jul 13, 2017
Length: 358 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288425
Vendor :
Docker
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 116.97
Learning Docker
€41.99
Deployment with Docker
€32.99
Docker on Windows
€41.99
Total 116.97 Stars icon

Table of Contents

12 Chapters
Getting Started with Docker on Windows Chevron down icon Chevron up icon
Packaging and Running Applications as Docker Containers Chevron down icon Chevron up icon
Developing Dockerized .NET and .NET Core Applications Chevron down icon Chevron up icon
Pushing and Pulling Images from Docker Registries Chevron down icon Chevron up icon
Adopting Container-First Solution Design Chevron down icon Chevron up icon
Organizing Distributed Solutions with Docker Compose Chevron down icon Chevron up icon
Orchestrating Distributed Solutions with Docker Swarm Chevron down icon Chevron up icon
Administering and Monitoring Dockerized Solutions Chevron down icon Chevron up icon
Understanding the Security Risks and Benefits of Docker Chevron down icon Chevron up icon
Powering a Continuous Deployment Pipeline with Docker Chevron down icon Chevron up icon
Debugging and Instrumenting Application Containers Chevron down icon Chevron up icon
Containerize What You Know - Guidance for Implementing Docker Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(14 Ratings)
5 star 85.7%
4 star 0%
3 star 0%
2 star 0%
1 star 14.3%
Filter icon Filter
Top Reviews

Filter reviews by




Dan Arnold Jun 25, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I found this book invaluable due to the specific coverage of Windows containers. Information on the internet is typically oriented towards Linux especially in the networking area.
Amazon Verified review Amazon
Amazon Customer Aug 11, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great introduction to Docker on Windows. I keep using it as a reference as I plow into Docker.
Amazon Verified review Amazon
Steven Follis Sep 08, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Thorough primer on Docker with excellent real world code samples. Highly recommended for professionals wanting to expand their skillsets with containers.
Amazon Verified review Amazon
peter de tender - Business Program Manager - Azure Technical Trainer at Microsoft Sep 20, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I was looking for a book to get me up-to-speed on Docker, and that's exaxtly what this book does. Starting from the basics of container concepts, Elton clearly describes the Docker features, the roadmap, best practices, all using super-cristal clear examples. Besides sharing his Docker experiences, Elton also shared his knowledge as a deep-dive technical .NET developer, walking you through step-by-step scenarios on how to cloud-enable and containerize your legacy applications. Great job done Elton!
Amazon Verified review Amazon
Brent Arias Oct 13, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I love this book. It is densely packed with fast-moving, insightful and real-world guidance. Other sources I've studied have been too context-free for my own tastes. In contrast, "Docker on Windows" has a writing style and progression of examples which, for me, have been perfect for comprehension and retention.The path carved by Microsoft to bring a native Docker to Windows is very exciting - and I've found Stoneman's book the perfect place to start mastering this new frontier. Just get it; you'll be glad you did.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.