Docker Cookbook - Second Edition

Book description

Leverage Docker to deploying software at scale

Key Features

  • Leverage practical examples to manage containers efficiently
  • Integrate with orchestration tools such as Kubernetes for controlled deployments
  • Learn to implement best practices on improving efficiency and security of containers

Book Description

Docker is an open source platform for building, shipping, managing, and securing containers. Docker has become the tool of choice for people willing to work with containers. Since the market is moving toward containerization, Docker will definitely have a big role to play in the future tech market.

This book starts with setting up Docker in different environment, and helps you learn how to work with Docker images. Then, you will take a deep dive into network and data management for containers. The book explores the RESTful APIs provided by Docker to perform different actions, such as image/container operations. The book then explores logs and troubleshooting Docker to solve issues and bottlenecks. You will gain an understanding of Docker use cases, orchestration, security, ecosystems, and hosting platforms to make your applications easy to deploy, build, and collaborate on. The book covers the new features of Docker 18.xx (or later), such as working with AWS and Azure, Docker Engine, Docker Swarm, Docker Compose, and so on.

By the end of this book, you will have gained hands-on experience of finding quick solutions to different problems encountered while working with Docker.

What you will learn

  • Install Docker on various platforms
  • Work with Docker images and containers
  • Container networking and data sharing
  • Docker APIs and language bindings
  • Various PaaS solutions for Docker
  • Implement container orchestration using Docker Swarm and Kubernetes
  • Container security
  • Docker on various clouds

Who this book is for

Book is targeted towards developers, system administrators, and DevOps engineers who want to use Docker in his/her development, QA, or production environments.

It is expected that the reader has basic Linux/Unix skills such as installing packages, editing files, managing services, and so on.

Any experience in virtualization technologies such as KVM, XEN, and VMware will be an added advantage

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Docker Cookbook Second Edition
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Get in touch
      1. Reviews
  7. Introduction and Installation
    1. Introduction
      1. Namespaces
        1. The PID namespace
        2. The net namespace
        3. The IPC namespace
        4. The mnt namespace
        5. The UTS namespace
        6. The user namespace
      2. Cgroups
      3. The union filesystem
      4. The container format
    2. Verifying requirements for Docker installation
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Installing Docker on Ubuntu
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Installing Docker on CentOS
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Installing Docker on Linux with an automated script
      1. Getting ready
      2. How to do it
      3. How it works...
      4. There's more...
    6. Installing Docker for Windows
      1. Getting ready
      2. How to do it
      3. How it works...
      4. There's more
      5. See also
    7. Installing Docker for Mac
      1. Getting ready
      2. How to do it
      3. How it works...
      4. There's more...
      5. See also
    8. Pulling an image and running a container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    9. Adding a nonroot user to administer Docker
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Finding help with the Docker command line
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
  8. Working with Docker Containers
    1. Introduction
    2. Listing/searching for an image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Pulling an image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Listing images
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Starting a container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Listing containers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Looking at the container logs
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    8. Stopping a container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    9. Removing a container
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. How it works...
      5. See also
    10. Removing all stopped containers
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. How it works...
      5. See also
    11. Setting the restart policy on a container
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    12. Getting privileged access inside a container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    13. Accessing the host device inside a container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    14. Injecting a new process into a running container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    15. Reading a container's metadata
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    16. Labeling and filtering containers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    17. Reaping a zombie inside a container
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. How it works...
      5. See also
  9. Working with Docker Images
    1. Introduction
    2. Creating an image from the container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Creating an account with Docker Hub
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Logging in and out of the Docker image registry
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Publishing an image to the registry
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Looking at the history of an image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Removing an image
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    8. Exporting an image
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    9. Importing an image
      1. Getting ready
      2. How to do it...
      3. There's more...
      4. See also
    10. Building an image using a Dockerfile
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    11. Building an Apache image – a Dockerfile example
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    12. Setting up a private index/registry
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    13. Automated builds – with GitHub and Bitbucket
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    14. Creating a custom base image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    15. Creating a minimal image using a scratch base image
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    16. Building images in multiple stages
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    17. Visualizing the image hierarchy
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  10. Network and Data Management for Containers
    1. Introduction
    2. Accessing containers from outside
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Attaching containers to a host network
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Launching containers with no network
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Sharing IP addresses with other containers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Creating a user-defined bridge network
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Discovering and load balancing containers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    8. Persisting data using volumes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    9. Sharing data between the host and the container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  11. Docker Use Cases
    1. Introduction
    2. Testing with Docker
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Performing CI/CD with Shippable and Heroku
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Performing CI/CD with TravisCI
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Setting up PaaS with OpenShift origin
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Building and deploying an app on OpenShift from the source code
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  12. Docker APIs and SDKs
    1. Introduction
    2. Working with images using APIs
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    3. Building images using APIs
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    4. Launching containers using APIs
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Performing container operations using APIs
      1. How to do it...
      2. How it works...
      3. See also
    6. Exploring Docker remote API client libraries
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    7. Configuring the Docker daemon for remote connectivity
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    8. Securing the Docker daemon's remote connectivity
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  13. Docker Performance
    1. Introduction
    2. Benchmarking CPU performance
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Benchmarking disk performance
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Benchmarking network performance
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Getting container resource usage using the stats feature
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Setting up performance monitoring
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  14. Docker Orchestration and Hosting a Platform
    1. Introduction
    2. Running applications with Docker Compose
      1. Getting ready
      2. How to do it
      3. How it works...
      4. There's more...
      5. See also
    3. Setting up a cluster with Docker Swarm
      1. Getting ready
      2. How to do it
      3. How it works...
      4. There's more...
      5. See also
    4. Using secrets with Docker Swarm
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Setting up a Kubernetes cluster
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Using secrets with Kubernetes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    7. Scaling up and down in Kubernetes cluster
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    8. Setting up WordPress with Kubernetes clusters
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  15. Docker Security
    1. Introduction
    2. Setting Mandatory Access Control (MAC) with SELinux
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Allowing writes to volumes mounted from the host with SELinux ON
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Removing capabilities to break down the power of a root user inside a container
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Sharing namespaces between the host and the container
      1. Getting ready
      2. How to do it...
      3. How it works...
  16. Getting Help and Tips and Tricks
    1. Introduction
    2. Starting Docker in debug mode
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Building a Docker binary from the source
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Building images without using cached layers
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Building your own bridge for container communication
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Changing the default OCI runtime
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    7. Selecting the logging driver for containers
      1. Getting ready
      2. How to do it
      3. How it works...
      4. There's more...
      5. See also
    8. Getting real-time Docker events for containers
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  17. Docker on the Cloud
    1. Introduction
    2. Docker for AWS
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
      5. See also
    3. Deploying WordPress on Docker for AWS
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Docker for Azure
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Deploying Joomla! on Docker for Azure
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Docker Cookbook - Second Edition
  • Author(s): Ken Cochrane, Jeeva S. Chelladhurai, Neependra K Khare
  • Release date: August 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788626866