Leanpub Header

Skip to main content

Docker Containers: From Beginner to Mastery

A Complete Guide to Building, Running, and Managing Containerized Applications

This book is 100% completeLast updated on 2026-07-17

Discover how Docker is revolutionizing modern software development by making applications faster to build, easier to deploy, and more reliable to run. Whether you are just getting started or refining production workflows, this practical guide will help you master containers through clear explanations, hands-on examples, and real-world techniques that you can apply with confidence.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
199
Pages
About

About

About the Book

Docker containers have fundamentally transformed how software is built, shipped, and run. This comprehensive guide takes you from zero container knowledge through advanced production patterns. You will learn Docker architecture, image building, networking, storage, security, orchestration, CI/CD integration, and real-world workflows. Every chapter includes practical examples, annotated command-line snippets, hands-on exercises, best practices, and common pitfalls. Whether you are a developer new to containers or an experienced DevOps engineer looking for advanced techniques, this book provides the complete knowledge path from first concepts to production-grade mastery.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 400 engineers and researchers from Ukraine, Belarus and Russia. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

A Complete Guide to Building, Running, and Managing Containerized Applications

Introduction: The Container Revolution

  1. What This Book Covers
  2. Who This Book Is For
  3. How to Use This Book
  4. Prerequisites and Setup
  5. The Journey Ahead

Chapter 1: The Container Revolution – Why Docker Changed Everything

  1. The Pre-Container Era: Virtual Machines and Their Limits
  2. What Is a Container? Linux Primitives Explained
  3. Docker vs. Virtual Machines: A Fundamental Comparison
  4. The Birth of Docker: From dotCloud to Open Source
  5. Why Containers Won: Speed, Density, and Portability
  6. Chapter Summary and Key Takeaways

Chapter 2: Installing Docker Across Platforms

  1. Docker Desktop: The Easiest Path for Developers
  2. Installing Docker on Linux (Ubuntu, Debian, CentOS, Fedora)
  3. Docker on Windows: WSL2 and Hyper-V Backends
  4. Docker Engine vs. Docker Desktop: Understanding the Difference
  5. Verifying Your Installation and Running Your First Container
  6. Common Installation Pitfalls and Fixes
  7. Chapter Summary and Key Takeaways

Chapter 3: Docker Architecture Under the Hood

  1. The Client-Server Architecture: Docker CLI and Docker Daemon
  2. Containerd and runc: The Runtime Stack
  3. How cgroups Isolate Resources
  4. How Namespaces Provide Isolation
  5. Union File Systems and Layered Storage Drivers
  6. The Docker API: RESTful Communication with the Daemon
  7. Chapter Summary and Key Takeaways

Chapter 4: Core Concepts – Images, Containers, and Layers

  1. Docker Images: Immutable, Layered Blueprints
  2. How Image Layers Work: The Union File System in Practice
  3. Running Containers: From Image to Process
  4. The Container Lifecycle: Create, Start, Stop, Remove
  5. Inspecting Images and Containers with the CLI
  6. Image Tags, Digests, and Versioning Strategies
  7. Chapter Summary and Key Takeaways

Chapter 5: Docker Registries – Publishing and Distributing Images

  1. Docker Hub: The Default Public Registry
  2. Pulling, Tagging, and Pushing Images
  3. Understanding Image Tags and the Latest Tag Problem
  4. Private Registries: Docker Trusted Registry and Alternatives
  5. Registry Security: Scanning, Signing, and Notary
  6. Managing Registry Storage and Cleanup Policies
  7. Chapter Summary and Key Takeaways

Chapter 6: Writing Dockerfiles – Building Custom Images

  1. Dockerfile Anatomy: Instructions and Syntax
  2. FROM, RUN, COPY, and ADD: The Core Instructions
  3. CMD vs ENTRYPOINT: Understanding Execution Models
  4. ENV, ARG, and EXPOSE: Configuration and Documentation
  5. WORKDIR, USER, HEALTHCHECK, and LABEL
  6. Best Practices for Dockerfile Authoring
  7. Common Dockerfile Anti-Patterns and How to Avoid Them
  8. Chapter Summary and Key Takeaways

Chapter 7: Multi-Stage Builds and Image Optimization

  1. The Problem: Bloated Docker Images
  2. Multi-Stage Builds: Concept and Syntax
  3. Real-World Multi-Stage Build Examples (Node.js, Go, Python)
  4. Distroless and Minimal Base Images
  5. Image Size Optimization Techniques
  6. Scanning and Analyzing Image Contents
  7. Chapter Summary and Key Takeaways

Chapter 8: Container Networking Deep Dive

  1. Docker Network Drivers: Bridge, Host, None, and Overlay
  2. The Default Bridge Network and Its Limitations
  3. Creating Custom Bridge Networks for Service Discovery
  4. Port Mapping: Published vs Exposed Ports
  5. Docker DNS and Container-to-Container Communication
  6. Overlay Networks for Multi-Host Communication
  7. Macvlan and IPvlan: Advanced Networking Drivers
  8. Chapter Summary and Key Takeaways

Chapter 9: Persistent Storage – Volumes, Bind Mounts, and tmpfs

  1. The Ephemeral Container Filesystem Problem
  2. Docker Volumes: Managed, Persistent Storage
  3. Bind Mounts: Bridging Host and Container Filesystems
  4. tmpfs Mounts: In-Memory, Ephemeral Storage
  5. Volume Drivers and Third-Party Storage Solutions
  6. Backup, Restore, and Migration Strategies for Container Data
  7. Chapter Summary and Key Takeaways

Chapter 10: Environment Variables, Secrets, and Configuration

  1. Environment Variables: -e, —env-file, and Dockerfile ENV
  2. The Twelve-Factor App Configuration Philosophy
  3. Docker Secrets: Secure Credential Management
  4. Config Files in Swarm Mode
  5. .env Files and Docker Compose Variable Substitution
  6. Security Implications of Storing Sensitive Data in Images
  7. Chapter Summary and Key Takeaways

Chapter 11: Docker Compose – Multi-Container Applications

  1. What Is Docker Compose and When to Use It
  2. The docker-compose.yml File: Structure and Syntax
  3. Services, Networks, and Volumes in Compose
  4. Compose Commands: Up, Down, Logs, Exec, and More
  5. Compose Profiles and Selective Service Management
  6. Multi-File Compose and Environment Overrides
  7. Real-World Compose Project: A Full-Stack Application
  8. Chapter Summary and Key Takeaways

Chapter 12: Logging, Monitoring, and Observability

  1. Docker Logging Drivers: json-file, syslog, journald, and More
  2. Collecting Container Logs with docker logs
  3. Log Rotation and Storage Management
  4. Container Health Checks: HEALTHCHECK Instruction
  5. Docker Stats and Resource Monitoring
  6. Integrating with External Monitoring (Prometheus, Datadog, ELK)
  7. Chapter Summary and Key Takeaways

Chapter 13: Docker Security Best Practices

  1. The Container Security Threat Model
  2. Image Security: Scanning for Vulnerabilities
  3. Running Containers as Non-Root Users
  4. Read-Only Filesystems and Minimal Capabilities
  5. Seccomp Profiles and AppArmor/SELinux Integration
  6. Securing the Docker Daemon and API
  7. Supply Chain Security: SBOM, Signing, and Provenance
  8. Chapter Summary and Key Takeaways

Chapter 14: Performance Tuning and Resource Management

  1. CPU Limits and Shares: Controlling Compute Resources
  2. Memory Limits, Swapping, and OOM Handling
  3. I/O Bandwidth and Block Device Weighting
  4. Pids Limit and Kernel Resource Constraints
  5. Container Density: Packing More Containers per Host
  6. Performance Profiling Tools and Techniques
  7. Chapter Summary and Key Takeaways

Chapter 15: Debugging and Troubleshooting Docker

  1. Common Docker Error Messages and Their Meanings
  2. Inspecting Container Health with docker inspect
  3. Executing into Running Containers for Live Debugging
  4. Analyzing Container Logs and Daemon Logs
  5. Network Troubleshooting: Connectivity Between Containers
  6. Storage Troubleshooting: Disk Space and Volume Issues
  7. Docker Events and Real-Time Diagnostics
  8. Chapter Summary and Key Takeaways

Chapter 16: CI/CD Integration with Docker

  1. Building Docker Images in CI Pipelines
  2. Caching Strategies for Faster Builds
  3. Automated Testing with Docker Compose
  4. Image Scanning as a Pipeline Gate
  5. Pushing to Registries from CI/CD
  6. Real-World CI/CD Pipeline Examples (GitHub Actions, GitLab CI, Jenkins)
  7. Chapter Summary and Key Takeaways

Chapter 17: Container Orchestration Fundamentals

  1. Why Single-Host Docker Is Not Enough for Production
  2. Docker Swarm: Built-In Orchestration
  3. Swarm Mode: Managers, Workers, and Services
  4. Deploying Stacks with Compose Files in Swarm
  5. Service Discovery, Load Balancing, and Rolling Updates
  6. Swarm vs Kubernetes: Choosing the Right Tool
  7. Chapter Summary and Key Takeaways

Chapter 18: Docker and Kubernetes

  1. Kubernetes Architecture at a Glance
  2. Pods, Containers, and the Relationship to Docker
  3. Deploying Docker Images on Kubernetes
  4. Kubernetes Services, ConfigMaps, and Secrets
  5. Helm Charts and Application Packaging
  6. Running Minikube and Kind for Local Development
  7. From Docker Compose to Kubernetes Manifests
  8. Chapter Summary and Key Takeaways

Chapter 19: Real-World Production Workflows

  1. The Modern Containerized Application Architecture
  2. Development Workflow: Local Docker Compose Setup
  3. Staging and Testing Environments
  4. Production Deployment Patterns
  5. Disaster Recovery and Backup Strategies
  6. Case Study: Containerizing a Full-Stack Web Application
  7. Chapter Summary and Key Takeaways

Chapter 20: Emerging Features and the Docker Ecosystem

  1. Docker BuildKit: The Next-Generation Build Engine
  2. Docker Compose V2: Plugin Architecture and Improvements
  3. Docker Desktop Extensions and Marketplace
  4. Container Image Formats: OCI, Docker Manifest, and Distribution Specs
  5. eBPF and Container Observability
  6. The Future of Containers: Wasm, Serverless, and Edge Computing
  7. Chapter Summary and Key Takeaways

Conclusion: The Container Journey Ahead

Glossary of Docker Terms

Interview Questions for Docker Roles

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub