Part 1. Understanding Docker containers and images
1 Before you begin
2 Understanding Docker and running Hello World
3 Building your own Docker images
5 Sharing images with Docker Hub and other registries
6 Using Docker volumes for persistent storage
Part 2. Running distributed applications in containers
7 Running multi-container apps with Docker Compose
8 Supporting reliability with health checks and dependency checks
9 Adding observability with containerized monitoring
10 Running multiple environments with Docker Compose
11 Building and testing applications with Docker and Docker Compose
Part 3. Running at scale with a container orchestrator
12 Understanding orchestration: Docker Swarm and Kubernetes
13 Deploying distributed applications as stacks in Docker Swarm
14 Automating releases with upgrades and rollbacks
15 Configuring Docker for secure remote access and CI/CD
16 Building Docker images that run anywhere: Linux, Windows, Intel, and Arm
Part 4. Getting your containers ready for production
17 Optimizing your Docker images for size, speed, and security
18 Application configuration management in containers
20 Controlling HTTP traffic to containers with a reverse proxy
, 21 Asynchronous communication with a message queue
22 Never the end
Part 1. Understanding Docker containers and
images
Welcome to Learn Docker in a Month of Lunches. This first part will get you up to speed quickly
on the core Docker concepts: containers, images, and registries. You’ll learn how to run
applications in containers, package your own applications in containers, and share those
applications for other people to use. You’ll also learn about storing data in Docker volumes and
how you can run stateful apps in containers. By the end of these first chapters, you’ll be
comfortable with all the fundamentals of Docker, and you’ll be learning with best practices baked
in from the start.
1 Before you begin
Docker is a platform for running applications in lightweight units called containers. Containers
have taken hold in software everywhere, from serverless functions in the cloud to strategic
planning in the enterprise. Docker is becoming a core competency for operators and developers
across the industry--in the 2019 Stack Overflow survey, Docker polled as people’s number one
“most wanted” technology ( http://mng.bz/04lW ).
And Docker is a simple technology to learn. You can pick up this book as a complete beginner,
and you’ll be running containers in chapter 2 and packaging applications to run in Docker in
chapter 3. Each chapter focuses on practical tasks, with examples and labs that work on any
machine that runs Docker--Windows, Mac, and Linux users are all welcome here.
The journey you’ll follow in this book has been honed over the many years I’ve been teaching
Docker. Every chapter is hands-on--except this one. Before you start learning Docker, it’s
important to understand just how containers are being used in the real world and the type of
problems they solve--that’s what I’ll cover here. This chapter also describes how I’ll be teaching
Docker, so you can figure out if this is the right book for you.
Now let’s look at what people are doing with containers--I’ll cover the five main scenarios where
organizations are seeing huge success with Docker. You’ll see the wide range of problems you can
solve with containers, some of which will certainly map to scenarios in your own work. By the
end of this chapter you’ll understand why Docker is a technology you need to know, and you’ll
see how this book will get you there.
, 1.1 Why containers will take over the world
My own Docker journey started in 2014 when I was working on a project delivering APIs for
Android devices. We started using Docker for development tools--source code and build servers.
Then we gained confidence and started running the APIs in containers for test environments. By
the end of the project, every environment was powered by Docker, including production, where
we had strict requirements for availability and scale.
When I moved off the project, the handover to the new team was a single README file in a
GitHub repo. The only requirement for building, deploying, and managing the app--in any
environment--was Docker. New developers just grabbed the source code and ran a single
command to build and run everything locally. Administrators used the exact same tools to deploy
and manage containers in the production cluster.
Normally on a project of that size, handovers take two weeks. New developers need to install
specific versions of half a dozen tools, and administrators need to install half a dozen completely
different tools. Docker centralizes the toolchain and makes everything so much easier for
everybody that I thought one day every project would have to use containers.
I joined Docker in 2016, and I’ve spent the last few years watching that vision becoming reality.
Docker is approaching ubiquity, partly because it makes delivery so much easier, and partly
because it’s so flexible--you can bring it into all your projects, old and new, Windows and Linux.
Let’s look at where containers fit in those projects.
1.1.1 Migrating apps to the cloud
Moving apps to the cloud is top of mind for many organizations. It’s an attractive option--let
Microsoft or Amazon or Google worry about servers, disks, networks, and power. Host your apps
across global datacenters with practically limitless potential to scale. Deploy to new environments
within minutes, and get billed only for the resources you’re using. But how do you get your apps
to the cloud?
There used to be two options for migrating an app to the cloud: infrastructure as a service (IaaS)
and platform as a service (PaaS). Neither option was great. Your choice was basically a
compromise--choose PaaS and run a project to migrate all the pieces of your application to the
relevant managed service from the cloud. That’s a difficult project and it locks you in to a single
cloud, but it does get you lower running costs. The alternative is IaaS, where you spin up a virtual
machine for each component of your application. You get portability across clouds but much
higher running costs. Figure 1.1 shows how a typical distributed application looks with a cloud
migration using IaaS and PaaS.