Preface
Section 1: Container Fundamentals and Best Practices
Chapter 1: The Move to Containers
The need for containers
The matrix of hell6
Virtual machines7
Containers8
It works on my machine9
Container architecture
Container networking11
Modern DevOps versus traditional DevOps
Containers and modern DevOps practices
Migrating from virtual machines to containers
Discovery17
Application requirement assessment 18
Container infrastructure design18
Containerizing the application19
Testing 19
Deployment and rollout20
What applications should go in containers?21
Breaking the applications into smaller pieces23
Are we there yet?
Summary
Questions
Answers
Chapter 2: Containerization with Docker
Technical requirements
Installing tools
Installing Git28
Installing vim29
Installing Docker
Introducing Docker storage drivers and volumes
Docker data storage options32
Mounting volumes33
,Docker storage drivers34
Configuring a storage driver35
Running your first container
Running containers from versioned images 37
Running Docker containers in the background38
Troubleshooting containers38
Putting it all together40
Restarting and removing containers42
Docker logging and logging drivers
Container log management43
Logging drivers43
Configuring logging drivers44
Typical challenges and best practices with Docker logging47
Docker monitoring with Prometheus
Challenges with container monitoring49
Installing Prometheus49
Configuring cAdvisor and the node exporter to expose metrics50
Configuring Prometheus to scrape metrics50
Launching a sample container application51
Metrics to monitor54
Declarative container management with Docker Compose
Installing Docker Compose56
Deploying a sample application with Docker Compose56
Creating the docker-compose file58
Docker Compose best practices61
Summary
Questions
Answers
Chapter 3: Creating and Managing Container Images
Technical requirements
Docker architecture
Understanding Docker images
The layered filesystem68
Image history69
Understanding Dockerfiles, components, and directives
Can we use ENTRYPOINT instead of CMD?72
, Are RUN and CMD the same?72
Building our first container73
Building and managing Docker images
Single-stage builds82
Multi-stage builds84
Managing Docker images86
Flattening Docker images91
Optimizing containers with distroless images
Performance93
Security94
Cost94
Understanding Docker registries
Hosting your private Docker registry97
Other public registries100
Summary
Questions
Answers
Chapter 4: Container Orchestration with Kubernetes – Part I
Technical requirements
What is Kubernetes and why do I need it?
Kubernetes architecture
Installing Kubernetes (Minikube and KinD)
Installing Minikube111
Installing KinD114
Understanding Kubernetes pods
Using port forwarding120
Troubleshooting pods121
Ensuring pod reliability124
Pod multi-container design patterns127
Summary
Questions
Answers
Chapter 5: Container Orchestration with Kubernetes – Part II
Technical requirements
Spinning up Google Kubernetes Engine152
Kubernetes Deployments