You are previewing Docker Cookbook.
O'Reilly logo
Docker Cookbook

Book Description

80 hands-on recipes to efficiently work with the Docker 1.6 environment on Linux

In Detail

Docker is a Linux container engine that allows you to create consistent, stable, and production-quality environments with containers.

You will start by installing Docker and understanding and working with containers and images. You then proceed to learn about network and data management for containers. The book explores the RESTful APIs provided by Docker to perform different actions such as image/container operations. Finally, the book explores logs and troubleshooting Docker to solve issues and bottlenecks. This book will also help you understand Docker use cases, orchestration, security, ecosystems, and hosting platforms to make your applications easy to deploy, build, and collaborate on.

What You Will Learn

  • Install and set up Docker on different environments

  • Work with Docker images and containers to Dockerize applications

  • Create services with Docker to enable the swift development and deployment of applications

  • Make optimum use of Docker in a testing environment do complete CI/CD

  • Plan efficient working with Docker APIs, orchestration, and hosting platform such as Project Atomic

  • Learn the various use cases available for Docker

  • Troubleshoot, maintain, and optimize your Docker services effectively

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Docker Cookbook
      1. Table of Contents
      2. Docker Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Sections
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Errata
          2. Piracy
          3. Questions
      8. 1. 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
        2. Verifying the requirements for Docker installation
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. Installing Docker
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more…
          5. See also
        4. 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
        5. Adding a nonroot user to administer Docker
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Setting up the Docker host with Docker Machine
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Finding help with the Docker command line
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
      9. 2. 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 logs of containers
          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. Deleting a container
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. How it works…
          5. See also
        10. Setting the restart policy on a container
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. See also
        11. 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
        12. Exposing a port while starting a container
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. See also
        13. Accessing the host device inside the container
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        14. Injecting a new process to a running container
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        15. Returning low-level information about a container
          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
      10. 3. Working with Docker Images
        1. Introduction
        2. Creating an account with Docker Hub
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        3. 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
        4. 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
        5. 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
        6. Deleting an image
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. See also
        7. Exporting an image
          1. Getting ready
          2. How to do it…
          3. There's more…
          4. See also
        8. Importing an image
          1. Getting ready
          2. How to do it…
          3. See also
        9. Building images using Dockerfiles
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        10. 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
        11. Accessing Firefox from a container – a Dockerfile example
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
          5. See also
        12. Building a WordPress image – a Dockerfile example
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        13. 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
        14. 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
        15. Creating the base image – using supermin
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        16. Creating the base image – using Debootstrap
          1. Getting ready
          2. How to do it…
          3. See also
        17. Visualizing dependencies between layers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      11. 4. 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. Managing data in containers
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more…
          5. See also
        4. Linking two or more containers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Developing a LAMP application by linking containers
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Networking of multihost containers with Flannel
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. Assigning IPv6 addresses to containers
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      12. 5. 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. Doing CI/CD with Shippable and Red Hat OpenShift
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        4. Doing CI/CD with Drone
          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 v3 from the source code
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        7. Configuring Docker as a hypervisor driver for OpenStack
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more…
          5. See also
      13. 6. Docker APIs and Language Bindings
        1. Introduction
        2. Configuring the Docker daemon remote API
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        3. Performing image operations using remote APIs
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Performing container operations using remote APIs
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        5. Exploring Docker remote API client libraries
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Securing the Docker daemon remote API
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more…
      14. 7. 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
      15. 8. Docker Orchestration and Hosting Platforms
        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 cluster with Docker Swarm
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        4. Setting up CoreOS for Docker orchestration
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        5. Setting up a Project Atomic host
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Doing atomic update/rollback with Project Atomic
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also
        7. Adding more storage for Docker in Project Atomic
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        8. Setting up Cockpit for Project Atomic
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        9. Setting up a Kubernetes cluster
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        10. Scaling up and down in a Kubernetes cluster
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        11. Setting up WordPress with a Kubernetes cluster
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
      16. 9. 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 volume 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 breakdown 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…
          4. There's more...
          5. See also
      17. 10. 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…
        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 execution driver of Docker
          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
      18. Index