Docker Cookbook

Book description

Whether you’re deploying applications on premise or in the cloud, this cookbook provides developers, operators, and IT professionals with more than 130 proven recipes for working with Docker.

With these practical solutions, experienced developers with no previous knowledge of Docker will be able to package and deploy distributed applications within a couple of chapters. IT professionals will be able to solve everyday problems, as well as create, run, share, and deploy Docker images. Operators will quickly be able to adopt the tools that will change the way they work.

The recipes in this book will help you:

  • Manage containers, mount data volumes, and link containers
  • Create and share container images
  • Network containers across single or multiple hosts
  • Tackle advanced topics such as Docker configuration and development
  • Deploy multi-container applications on a distributed cluster with Kubernetes
  • Use a new generation of operating systems optimized for Docker
  • Learn tools for application deployment, continuous integration, service discovery, and orchestration
  • Access a Docker host on Amazon AWS, Google GCE, and Microsoft Azure
  • Monitor containers and explore different application use cases

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Why I Wrote This Book
    2. How This Book Is Organized
    3. Technology You Need to Understand
    4. Online Content
    5. Conventions Used in This Book
    6. Safari® Books Online
    7. How to Contact Us
    8. Acknowledgments
  2. Getting Started with Docker
    1. 1.0 Introduction
    2. 1.1 Installing Docker on Ubuntu 14.04
    3. 1.2 Installing Docker on CentOS 6.5
    4. 1.3 Installing Docker on CentOS 7
    5. 1.4 Setting Up a Local Docker Host by Using Vagrant
    6. 1.5 Installing Docker on a Raspberry Pi
    7. 1.6 Installing Docker on OS X Using Docker Toolbox
    8. 1.7 Using Boot2Docker to Get a Docker Host on OS X
    9. 1.8 Running Boot2Docker on Windows 8.1 Desktop
    10. 1.9 Starting a Docker Host in the Cloud by Using Docker Machine
    11. 1.10 Using Docker Experimental Binaries
    12. 1.11 Running Hello World in Docker
    13. 1.12 Running a Docker Container in Detached Mode
    14. 1.13 Creating, Starting, Stopping, and Removing Containers
    15. 1.14 Building a Docker Image with a Dockerfile
    16. 1.15 Using Supervisor to Run WordPress in a Single Container
    17. 1.16 Running a WordPress Blog Using Two Linked Containers
    18. 1.17 Backing Up a Database Running in a Container
    19. 1.18 Sharing Data in Your Docker Host with Containers
    20. 1.19 Sharing Data Between Containers
    21. 1.20 Copying Data to and from Containers
  3. Image Creation and Sharing
    1. 2.0 Introduction
    2. 2.1 Keeping Changes Made to a Container by Committing to an Image
    3. 2.2 Saving Images and Containers as Tar Files for Sharing
    4. 2.3 Writing Your First Dockerfile
    5. 2.4 Packaging a Flask Application Inside a Container
    6. 2.5 Optimizing Your Dockerfile by Following Best Practices
    7. 2.6 Versioning an Image with Tags
    8. 2.7 Migrating from Vagrant to Docker with the Docker Provider
    9. 2.8 Using Packer to Create a Docker Image
    10. 2.9 Publishing Your Image to Docker Hub
    11. 2.10 Using ONBUILD Images
    12. 2.11 Running a Private Registry
    13. 2.12 Setting Up an Automated Build on Docker Hub for Continuous Integration/Deployment
    14. 2.13 Setting Up a Local Automated Build by Using a Git Hook and a Private Registry
    15. 2.14 Using Conduit for Continuous Deployment
  4. Docker Networking
    1. 3.0 Introduction
    2. 3.1 Finding the IP Address of a Container
    3. 3.2 Exposing a Container Port on the Host
    4. 3.3 Linking Containers in Docker
    5. 3.4 Understanding Docker Container Networking
    6. 3.5 Choosing a Container Networking Namespace
    7. 3.6 Configuring the Docker Daemon IP Tables and IP Forwarding Settings
    8. 3.7 Using pipework to Understand Container Networking
    9. 3.8 Setting Up a Custom Bridge for Docker
    10. 3.9 Using OVS with Docker
    11. 3.10 Building a GRE Tunnel Between Docker Hosts
    12. 3.11 Running Containers on a Weave Network
    13. 3.12 Running a Weave Network on AWS
    14. 3.13 Deploying flannel Overlay Between Docker Hosts
    15. 3.14 Networking Containers on Multiple Hosts with Docker Network
    16. 3.15 Diving Deeper into the Docker Network Namespaces Configuration
  5. Docker Configuration and Development
    1. 4.0 Introduction
    2. 4.1 Managing and Configuring the Docker Daemon
    3. 4.2 Compiling Your Own Docker Binary from Source
    4. 4.3 Running the Docker Test Suite for Docker Development
    5. 4.4 Replacing Your Current Docker Binary with a New One
    6. 4.5 Using nsenter
    7. 4.6 Introducing runc
    8. 4.7 Accessing the Docker Daemon Remotely
    9. 4.8 Exploring the Docker Remote API to Automate Docker Tasks
    10. 4.9 Securing the Docker Daemon for Remote Access
    11. 4.10 Using docker-py to Access the Docker Daemon Remotely
    12. 4.11 Using docker-py Securely
    13. 4.12 Changing the Storage Driver
  6. Kubernetes
    1. 5.0 Introduction
    2. 5.1 Understanding Kubernetes Architecture
    3. 5.2 Networking Pods for Container Connectivity
    4. 5.3 Creating a Multinode Kubernetes Cluster with Vagrant
    5. 5.4 Starting Containers on a Kubernetes Cluster with Pods
    6. 5.5 Taking Advantage of Labels for Querying Kubernetes Objects
    7. 5.6 Using a Replication Controller to Manage the Number of Replicas of a Pod
    8. 5.7 Running Multiple Containers in a Pod
    9. 5.8 Using Cluster IP Services for Dynamic Linking of Containers
    10. 5.9 Creating a Single-Node Kubernetes Cluster Using Docker Compose
    11. 5.10 Compiling Kubernetes to Create Your Own Release
    12. 5.11 Starting Kubernetes Components with the hyperkube Binary
    13. 5.12 Exploring the Kubernetes API
    14. 5.13 Running the Kubernetes Dashboard
    15. 5.14 Upgrading from an Old API Version
    16. 5.15 Configuring Authentication to a Kubernetes Cluster
    17. 5.16 Configuring the Kubernetes Client to Access Remote Clusters
  7. Optimized Operating System Distributions for Docker
    1. 6.0 Introduction
    2. 6.1 Discovering the CoreOS Linux Distribution with Vagrant
    3. 6.2 Starting a Container on CoreOS via cloud-init
    4. 6.3 Starting a CoreOS Cluster via Vagrant to Run Containers on Multiple Hosts
    5. 6.4 Using fleet to Start Containers on a CoreOS Cluster
    6. 6.5 Deploying a flannel Overlay Between CoreOS Instances
    7. 6.6 Using Project Atomic to Run Docker Containers
    8. 6.7 Starting an Atomic Instance on AWS to Use Docker
    9. 6.8 Running Docker on Ubuntu Core Snappy in a Snap
    10. 6.9 Starting an Ubuntu Core Snappy Instance on AWS EC2
    11. 6.10 Running Docker Containers on RancherOS
  8. The Docker Ecosystem: Tools
    1. 7.0 Introduction
    2. 7.1 Using Docker Compose to Create a WordPress Site
    3. 7.2 Using Docker Compose to Test Apache Mesos and Marathon on Docker
    4. 7.3 Starting Containers on a Cluster with Docker Swarm
    5. 7.4 Using Docker Machine to Create a Swarm Cluster Across Cloud Providers
    6. 7.5 Managing Containers Locally Using the Kitematic UI
    7. 7.6 Managing Containers Through Docker UI
    8. 7.7 Using the Wharfee Interactive Shell
    9. 7.8 Orchestrating Containers with Ansible Docker Module
    10. 7.9 Using Rancher to Manage Containers on a Cluster of Docker Hosts
    11. 7.10 Running Containers on a Cluster Using Lattice
    12. 7.11 Running Containers via Apache Mesos and Marathon
    13. 7.12 Using the Mesos Docker Containerizer on a Mesos Cluster
    14. 7.13 Discovering Docker Services with Registrator
  9. Docker in the Cloud
    1. 8.0 Introduction
    2. 8.1 Accessing Public Clouds to Run Docker
    3. 8.2 Starting a Docker Host on AWS EC2
    4. 8.3 Starting a Docker Host on Google GCE
    5. 8.4 Starting a Docker Host on Microsoft Azure
    6. 8.5 Starting a Docker Host on AWS Using Docker Machine
    7. 8.6 Starting a Docker Host on Azure with Docker Machine
    8. 8.7 Running a Cloud Provider CLI in a Docker Container
    9. 8.8 Using Google Container Registry to Store Your Docker Images
    10. 8.9 Using Docker in GCE Google-Container Instances
    11. 8.10 Using Kubernetes in the Cloud via GCE
    12. 8.11 Setting Up to Use the EC2 Container Service
    13. 8.12 Creating an ECS Cluster
    14. 8.13 Starting Docker Containers on an ECS Cluster
    15. 8.14 Starting an Application in the Cloud Using Docker Support in AWS Beanstalk
  10. Monitoring Containers
    1. 9.0 Introduction
    2. 9.1 Getting Detailed Information About a Container with docker inspect
    3. 9.2 Obtaining Usage Statistics of a Running Container
    4. 9.3 Listening to Docker Events on Your Docker Hosts
    5. 9.4 Getting the Logs of a Container with docker logs
    6. 9.5 Using a Different Logging Driver than the Docker Daemon
    7. 9.6 Using Logspout to Collect Container Logs
    8. 9.7 Managing Logspout Routes to Store Container Logs
    9. 9.8 Using Elasticsearch and Kibana to Store and Visualize Container Logs
    10. 9.9 Using Collectd to Visualize Container Metrics
    11. 9.10 Using cAdvisor to Monitor Resource Usage in Containers
    12. 9.11 Monitoring Container Metrics with InfluxDB, Grafana, and cAdvisor
    13. 9.12 Gaining Visibility into Your Containers’ Layout with Weave Scope
  11. Application Use Cases
    1. 10.0 Introduction
    2. 10.1 CI/CD: Setting Up a Development Environment
    3. 10.2 CI/CD: Building a Continuous Delivery Pipeline with Jenkins and Apache Mesos
    4. 10.3 ELB: Creating a Dynamic Load-Balancer with Confd and Registrator
    5. 10.4 DATA: Building an S3-Compatible Object Store with Cassandra on Kubernetes
    6. 10.5 DATA: Building a MySQL Galera Cluster on a Docker Network
    7. 10.6 DATA: Dynamically Configuring a Load-Balancer for a MySQL Galera Cluster
    8. 10.7 DATA: Creating a Spark Cluster
  12. Index

Product information

  • Title: Docker Cookbook
  • Author(s): Sébastien Goasguen
  • Release date: December 2015
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491919712