0%

Book Description

A practical guide to rapidly and efficiently mastering Docker containers, along with tips and tricks learned in the field.

About This Book

  • Use Docker containers, horizontal node scaling, modern orchestration tools (Docker Swarm, Kubernetes, and Mesos) and Continuous Integration/Continuous Delivery to manage your infrastructure.
  • Increase service density by turning often-idle machines into hosts for numerous Docker services.
  • Learn what it takes to build a true container infrastructure that is scalable, reliable, and resilient in the face of increased complexities from using container infrastructures.
  • Find out how to identify, debug, and mitigate most real-world, undocumented issues when deploying your own Docker infrastructure.
  • Learn tips and tricks of the trade from existing Docker infrastructures running in production environments.

Who This Book Is For

This book is aimed at system administrators, developers, DevOps engineers, and software engineers who want to get concrete, hands-on experience deploying multi-tier web applications and containerized microservices using Docker. This book is also for anyone who has worked on deploying services in some fashion and wants to take their small-scale setups to the next level (or simply to learn more about the process).

What You Will Learn

  • Set up a working development environment and create a simple web service to demonstrate the basics
  • Learn how to make your service more usable by adding a database and an app server to process logic
  • Add resilience to your services by learning how to horizontally scale with a few containers on a single node
  • Master layering isolation and messaging to simplify and harden the connectivity between containers
  • Learn about numerous issues encountered at scale and their workarounds, from the kernel up to code versioning
  • Automate the most important parts of your infrastructure with continuous integration

In Detail

Deploying Docker into production is considered to be one of the major pain points in developing large-scale infrastructures, and the documentation available online leaves a lot to be desired. With this book, you will learn everything you wanted to know to effectively scale your deployments globally and build a resilient, scalable, and containerized cloud platform for your own use.

The book starts by introducing you to the containerization ecosystem with some concrete and easy-to-digest examples; after that, you will delve into examples of launching multiple instances of the same container. From there, you will cover orchestration, multi-node setups, volumes, and almost every relevant component of this new approach to deploying services. Using intertwined approaches, the book will cover battle-tested tooling, or issues likely to be encountered in real-world scenarios, in detail. You will also learn about the other supporting components required for a true PaaS deployment and discover common options to tie the whole infrastructure together.

At the end of the book, you learn to build a small, but functional, PaaS (to appreciate the power of the containerized service approach) and continue to explore real-world approaches to implementing even larger global-scale services.

Style and approach

This in-depth learning guide shows you how to deploy your applications in production using Docker (from the basic steps to advanced concepts) and how to overcome challenges in Docker-based infrastructures. The book also covers practical use-cases in real-world examples, and provides tips and tricks on the various topics.

Table of Contents

  1. Title Page
  2. Copyright
    1. Deployment with Docker
  3. Credits
  4. About the Author
  5. Acknowledgments
  6. About the Reviewer
  7. www.PacktPub.com
    1. Why subscribe?
  8. Customer Feedback
  9. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  10. Containers - Not Just Another Buzzword
    1. The what and why of containers
    2. Docker's place
      1. Introduction to Docker containers
    3. The competition
      1. rkt
      2. System-level virtualization
      3. Desktop application-level virtualizations
    4. When should containerization be considered?
    5. The ideal Docker deployment
    6. The container mindset
      1. The developer workflow
    7. Summary
  11. Rolling Up the Sleeves
    1. Installing Docker
    2. Debugging containers
      1. Seeing what the container sees
    3. Our first Dockerfile
      1. Breaking the cache
    4. A container more practical
      1. Extending another container with FROM
      2. Ensuring the latest patches are included
      3. Applying our custom NGINX configuration
      4. Building and running
    5. Service from scratch
      1. Labels
      2. Setting environment variables with ENV
      3. Exposing ports
      4. Container security layering with limited users
      5. VOLUMEs and data that lives outside of the container
      6. Setting the working directory
      7. Adding files from the internet
      8. Changing the current user
      9. Putting it all together
    6. Summary
  12. Service Decomposition
    1. A quick review
      1. Docker commands
      2. Dockerfile commands
    2. Writing a real service
      1. An overview
      2. What we are going to build
      3. The implementation
        1. Web server
          1. Authentication
        2. The database
        3. The application server
          1. The main application logic
      4. Running it all together
        1. Launching
        2. Testing
      5. Limitations and issues with our implementation
        1. Fixing the critical issues
          1. Using a local volume
          2. Generating the credentials at runtime
    3. Introducing Docker networking
    4. Summary
  13. Scaling the Containers
    1. Service discovery
      1. A recap of Docker networking
      2. Service Discovery in depth
        1. Client-side discovery pattern
        2. Server-side discovery pattern
        3. Hybrid systems
        4. Picking the (un)available options
    2. Container orchestration
      1. State reconciliation
      2. Docker Swarm
      3. Kubernetes
      4. Apache Mesos/Marathon
      5. Cloud-based offerings
    3. Implementing orchestration
      1. Setting up a Docker Swarm cluster
        1. Initializing a Docker Swarm cluster
        2. Deploying services
        3. Cleaning up
      2. Using Swarm to orchestrate our words service
        1. The application server
          1. index.js
        2. The web server
        3. Database
        4. Deploying it all
        5. The Docker stack
        6. Clean up
    4. Summary
  14. Keeping the Data Persistent
    1. Docker image internals
      1. How images are layered
        1. Persisting the writable CoW layer(s)
      2. Running your own image registry
      3. Underlying storage driver
        1. aufs
        2. btrfs / zfs
        3. overlay and overlay2
        4. devicemapper
      4. Cleanup of Docker storage
        1. Manual cleanup
        2. Automatic cleanup
    2. Persistent storage
      1. Node-local storage
        1. Bind mounts
          1. Read-only bind mounts
        2. Named volumes
        3. Relocatable volumes
          1. Relocatable volume sync loss
    3. UID/GID and security considerations with volumes
    4. Summary
  15. Advanced Deployment Topics
    1. Advanced debugging
      1. Attaching to a container's process space
        1. Debugging the Docker daemon
    2. Advanced networking
      1. Static host configuration
      2. DNS configuration
      3. Overlay networks
      4. Docker built-in network mappings
      5. Docker communication ports
    3. High availability pipelines
      1. Container messaging
        1. Implementing our own messaging queue
          1. package.json
          2. index.js
          3. Dockerfile
    4. Advanced security
      1. Mounting the Docker socket into the container
      2. Host security scans
      3. Read-only containers
      4. Base system (package) updates
      5. Privileged mode versus --cap-add and --cap-drop
    5. Summary
  16. The Limits of Scaling and the Workarounds
    1. Limiting service resources
      1. RAM limits
      2. CPU limits
    2. Pitfall avoidance
      1. ulimits
      2. Max file descriptors
      3. Socket buffers
      4. Ephemeral ports
      5. Netfilter tweaks
      6. Multi-service containers
    3. Zero-downtime deployments
      1. Rolling service restarts
      2. Blue-green deployments
      3. Blue-turquoise-green deployments
    4. Summary
  17. Building Our Own Platform
    1. Configuration management
      1. Ansible
        1. Installation
        2. Basics
        3. Usage
      2. Amazon Web Services setup
        1. Creating an account
        2. Getting API keys
        3.  Using the API keys
      3. HashiCorp Packer
        1. Installation
        2. Usage
          1. Choosing the right AMI base image
        3. Building the AMI
    2. Deployments to AWS
      1. The road to automated infrastructure deployment
        1. Running the deployment and tear-down playbooks
    3. Continuous integration/Continuous delivery
      1. Resource considerations
      2. First-deploy circular dependency
      3. Further generic CI/CD uses
    4. Summary
  18. Exploring the Largest-Scale Deployments
    1. Maintaining quorums
    2. Node automation
      1. Reactive auto-scaling
      2. Predictive auto-scaling
    3. Monitoring
    4. Evaluating next-gen technologies
      1. Technological needs
      2. Popularity
      3. A team's technical competency
    5. Summary
3.145.65.134