O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Docker: Up & Running, 2nd Edition

Book Description

Docker is rapidly changing the way organizations deploy software at scale. However, understanding how Linux containers fit into your workflow—and getting the integration details right—is not a trivial task. With the updated edition of this practical guide, you’ll learn how to use Docker to package your applications with all of their dependencies and then test, ship, scale, and support your containers in production.

This edition includes significant updates to the examples and explanations that reflect the substantial changes that have occurred over the past couple of years. Sean Kane and Karl Matthias have added a complete chapter on Docker Compose, deeper coverage of Docker Swarm mode, introductions to both Kubernetes and AWS Fargate, examples on how to optimize your Docker images, and much more.

  • Learn how Docker simplifies dependency management and deployment workflow for your applications
  • Start working with Docker images, containers, and command line tools
  • Use practical techniques to deploy and test Docker containers in production
  • Debug containers by understanding their composition and internal processes
  • Deploy production containers at scale inside your data center or cloud environment
  • Explore advanced Docker topics, including deployment tools, networking, orchestration, security, and configuration

Table of Contents

  1. Foreword
  2. Preface
    1. Who Should Read This Book
    2. Why Read This Book?
    3. Navigating This Book
    4. Conventions Used in This Book
    5. Using Code Examples
    6. O’Reilly Safari
    7. How to Contact Us
    8. Acknowledgments
  3. 1. Introduction
    1. The Promise of Docker
      1. Benefits of the Docker Workflow
    2. What Docker Isn’t
    3. Important Terminology
    4. Wrap-Up
  4. 2. The Docker Landscape
    1. Process Simplification
    2. Broad Support and Adoption
    3. Architecture
      1. Client/Server Model
      2. Network Ports and Unix Sockets
      3. Robust Tooling
      4. Docker Command-Line Tool
      5. Docker Engine API
      6. Container Networking
    4. Getting the Most from Docker
      1. Containers Are Not Virtual Machines
      2. Limited Isolation
      3. Containers Are Lightweight
      4. Toward an Immutable Infrastructure
      5. Stateless Applications
      6. Externalizing State
    5. The Docker Workflow
      1. Revision Control
      2. Building
      3. Testing
      4. Packaging
      5. Deploying
      6. The Docker Ecosystem
    6. Wrap-Up
  5. 3. Installing Docker
    1. Docker Client
      1. Linux
      2. macOS, Mac OS X
      3. Microsoft Windows 10 Professional
    2. Docker Server
      1. systemd-Based Linux
      2. Non-Linux VM-Based Server
    3. Testing the Setup
      1. Ubuntu
      2. Fedora
      3. Alpine Linux
    4. Exploring the Docker Server
    5. Wrap-Up
  6. 4. Working with Docker Images
    1. Anatomy of a Dockerfile
    2. Building an Image
    3. Troubleshooting Broken Builds
    4. Running Your Image
      1. Environment Variables
    5. Custom Base Images
    6. Storing Images
      1. Public Registries
      2. Private Registries
      3. Authenticating to a Registry
      4. Running a Private Registry
    7. Advanced Building Techniques
      1. Keeping Images Small
      2. Layers Are Additive
      3. Optimizing for the Cache
    8. Wrap-Up
  7. 5. Working with Docker Containers
    1. What Are Containers?
      1. History of Containers
    2. Creating a Container
      1. Basic Configuration
      2. Storage Volumes
      3. Resource Quotas
    3. Starting a Container
    4. Auto-Restarting a Container
    5. Stopping a Container
    6. Killing a Container
    7. Pausing and Unpausing a Container
    8. Cleaning Up Containers and Images
    9. Windows Containers
    10. Wrap-Up
  8. 6. Exploring Docker
    1. Printing the Docker Version
    2. Server Information
    3. Downloading Image Updates
    4. Inspecting a Container
    5. Exploring the Shell
    6. Returning a Result
    7. Getting Inside a Running Container
      1. docker exec
      2. nsenter
      3. docker volume
    8. Logging
      1. docker logs
      2. More Advanced Logging
      3. Non-Plug-In Community Options
    9. Monitoring Docker
      1. Container Stats
      2. Container Health Checks
      3. Docker Events
      4. cAdvisor
    10. Prometheus Monitoring
    11. Exploration
    12. Wrap-Up
  9. 7. Debugging Containers
    1. Process Output
    2. Process Inspection
    3. Controlling Processes
    4. Network Inspection
    5. Image History
    6. Inspecting a Container
    7. Filesystem Inspection
    8. Wrap-Up
  10. 8. Exploring Docker Compose
    1. Configuring Docker Compose
    2. Launching Services
    3. Exploring RocketChat
    4. Exercising Docker Compose
    5. Wrap-Up
  11. 9. The Path to Production Containers
    1. Getting to Production
    2. Docker’s Role in Production Environments
      1. Job Control
      2. Resource Limits
      3. Networking
      4. Configuration
      5. Packaging and Delivery
      6. Logging
      7. Monitoring
      8. Scheduling
      9. Service Discovery
      10. Production Wrap-Up
    3. Docker and the DevOps Pipeline
      1. Quick Overview
      2. Outside Dependencies
    4. Wrap-Up
  12. 10. Docker at Scale
    1. Centurion
    2. Docker Swarm Mode
    3. Amazon ECS and Fargate
      1. Core AWS Setup
      2. IAM Role Setup
      3. AWS CLI Setup
      4. Container Instances
      5. Tasks
      6. Testing the Task
      7. Stopping the Task
    4. Kubernetes
      1. What Is Minikube?
      2. Installing Minikube
      3. Running Kubernetes
      4. Kubernetes Dashboard
      5. Kubernetes Containers and Pods
      6. Let’s Deploy Something
      7. Deploying a Realistic Stack
      8. Service Definition
      9. PersistentVolumeClaim Definition
      10. Deployment Definition
      11. Deploying the Application
      12. Scaling Up
      13. kubectl API
    5. Wrap-Up
  13. 11. Advanced Topics
    1. Containers in Detail
      1. cgroups
      2. Namespaces
    2. Security
      1. UID 0
      2. Privileged Containers
      3. Secure Computing Mode
      4. SElinux and AppArmor
      5. The Docker Daemon
    3. Advanced Configuration
      1. Networking
    4. Storage
    5. The Structure of Docker
    6. Swapping Runtimes
      1. gVisor
    7. Wrap-Up
  14. 12. Container Platform Design
    1. The Twelve-Factor App
      1. Codebase
      2. Dependencies
      3. Config
      4. Backing Services
      5. Build, Release, Run
      6. Processes
      7. Port Binding
      8. Concurrency
      9. Disposability
      10. Development/Production Parity
      11. Logs
      12. Admin Processes
      13. Twelve-Factor Wrap-Up
    2. The Reactive Manifesto
      1. Responsive
      2. Resilient
      3. Elastic
      4. Message-Driven
    3. Wrap-Up
  15. 13. Conclusion
    1. The Challenges Docker Addresses
    2. The Docker Workflow
    3. Minimizing Deployment Artifacts
    4. Optimizing Storage and Retrieval
    5. The Payoff
    6. The Final Word
  16. Index