Mastering Docker - Fourth Edition

Book description

Unlock the full potential of the Docker containerization platform with this practical guide

Key Features

  • Explore tools such as Docker Engine, Machine, Compose, and Swarm
  • Discover how you can integrate Docker into your everyday workflows
  • Get well-versed with Kubernetes options such as Minikube, Kind, and MicroK8s

Book Description

Docker has been a game changer when it comes to how modern applications are deployed and created. It has now grown into a key driver of innovation beyond system administration, with a significant impact on the world of web development. Mastering Docker shows you how you can ensure that you're keeping up with the innovations it's driving and be sure you're using it to its full potential. This fourth edition not only demonstrates how to use Docker more effectively but also helps you rethink and reimagine what you can achieve with it.

You'll start by building, managing, and storing images along with exploring best practices for working with Docker confidently. Once you've got to grips with Docker security, the book covers essential concepts for extending and integrating Docker in new and innovative ways. You'll also learn how to take control of your containers efficiently using Docker Compose, Docker Swarm, and Kubernetes.

By the end of this Docker book, you'll have a broad yet detailed sense of what's possible with Docker and how seamlessly it fits in with a range of other platforms and tools.

What you will learn

  • Get to grips with essential Docker components and concepts
  • Discover the best ways to build, store, and distribute container images
  • Understand how Docker can fit into your development workflow
  • Secure your containers and files with Docker's security features
  • Explore first-party and third-party cluster tools and plugins
  • Launch and manage your Kubernetes clusters in major public clouds

Who this book is for

If you are a software architect, DevOps engineer, sysadmin, or IT professional looking to leverage Docker's extensive features for innovating any process from system administration to web development, Mastering Docker will show you how you can use it to its full potential. A basic understanding of containerization and prior Docker experience is necessary.

Publisher resources

Download Example Code

Table of contents

  1. Mastering Docker, Fourth Edition
  2. Why subscribe?
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Packt is searching for authors like you
  7. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Code in Action
    6. Download the color images
    7. Conventions used
    8. Get in touch
    9. Reviews
  8. Section 1: Getting Up and Running with Docker
  9. Chapter 1: Docker Overview
    1. Technical requirements
    2. Understanding Docker
      1. Developers
      2. Operators
      3. Enterprise
    3. Docker installation
      1. Installing Docker on Linux
      2. Installing Docker on macOS
      3. Installing Docker on Windows 10 Professional
      4. Older operating systems
    4. Using Docker commands
    5. Docker and the container ecosystem
      1. Open source projects
      2. Docker, Inc.
      3. Docker CE and Docker EE
    6. Summary
    7. Questions
    8. Further reading
  10. Chapter 2: Building Container Images
    1. Technical requirements
    2. Introducing Dockerfiles
      1. Reviewing Dockerfiles in depth
      2. FROM
      3. LABEL
      4. RUN
      5. COPY and ADD
      6. Other Dockerfile instructions
      7. Dockerfiles – best practices
    3. Building Docker images
      1. Using a Dockerfile
      2. Using an existing container
      3. Using ENVs
      4. Using multi-stage builds
    4. Summary
    5. Questions
    6. Further reading
  11. Chapter 3: Storing and Distributing Images
    1. Technical requirements
    2. Understanding Docker Hub
      1. The Docker Hub Dashboard
      2. Creating an automated build
      3. Setting up your code
      4. Setting up Docker Hub
      5. Pushing your own image
      6. Docker Certified Images and Verified Publishers
    3. Deploying your own Docker Registry
      1. An overview of Docker Registry
      2. Deploying your own registry
      3. Docker Trusted Registry
    4. Reviewing third-party registries
      1. GitHub Packages and Actions
      2. Azure Container Registry
    5. Summary
    6. Questions
    7. Further reading
  12. Chapter 4: Managing Containers
    1. Technical requirements
    2. Understanding Docker container commands
      1. The basics
      2. Interacting with your containers
      3. logs
      4. top
      5. stats
      6. Resource limits
      7. Container states and miscellaneous commands
    3. Docker networking and volumes
      1. Docker volumes
    4. Docker Desktop Dashboard
    5. Summary
    6. Questions
    7. Further reading
  13. Chapter 5: Docker Compose
    1. Technical requirements
    2. Exploring the basics of Docker Compose
      1. Orchard Laboratories
    3. Making our first Docker Compose application
      1. Docker Compose YAML file
      2. The Moby counter application
      3. Example voting application
    4. Exploring Docker Compose commands
      1. config
      2. pull, build, and create
      3. start, stop, restart, pause, and unpause
      4. scale
    5. Using Docker App
      1. Defining the application
      2. Validating and inspecting the application
      3. Launching the app
      4. Pushing to Docker Hub
      5. Installing from Docker Hub
    6. Questions
    7. Further reading
  14. Chapter 6: Docker Machine, Vagrant, and Multipass
    1. Technical requirements
    2. An introduction to Docker Machine
      1. Installing Docker Machine using Docker Toolbox
      2. Installing Docker Machine using the command line
    3. Deploying local Docker hosts with Docker Machine
    4. Launching Docker hosts in the cloud using Docker Machine
      1. Docker Machine summary
      2. Introducing and using Vagrant
    5. Introducing and using Multipass
    6. Summary
    7. Questions
    8. Further reading
  15. Section 2: Clusters and Clouds
  16. Chapter 7: Moving from Linux to Windows Containers
    1. Technical requirements
    2. Setting up your Docker host for Windows containers
      1. Enabling Windows Container Support on Windows 10 Professional
      2. Up and running on MacOS and Linux
    3. Running Windows containers
    4. A Windows container Dockerfile
    5. Windows containers and Docker Compose
    6. Summary
    7. Questions
    8. Further reading
  17. Chapter 8: Clustering with Docker Swarm
    1. Technical requirements
    2. Introducing Docker Swarm
      1. Roles within a Docker Swarm cluster
    3. Creating and managing a Swarm
      1. Creating the cluster hosts
      2. Adding a Swarm manager to the cluster
      3. Joining Swarm workers to the cluster
      4. Listing nodes
    4. Managing a cluster
      1. Finding information on the cluster
      2. Promoting a worker node
      3. Demoting a manager node
      4. Draining a node
    5. Docker Swarm services and stacks
      1. Services
      2. Stacks
      3. Deleting a Swarm cluster
    6. Load balancing, overlays, and scheduling
      1. Ingress load balancing
      2. Network overlays
      3. Scheduling
    7. Summary
    8. Questions
    9. Further reading
  18. Chapter 9: Portainer – A GUI for Docker
    1. Technical requirements
    2. The road to Portainer
    3. Getting Portainer up and running
    4. Using Portainer
      1. The dashboard
      2. Application templates
      3. Containers
    5. Portainer and Docker Swarm
      1. Creating the Swarm
      2. The Portainer service
      3. Swarm differences
    6. Summary
    7. Questions
    8. Further reading
  19. Chapter 10: Running Docker in Public Clouds
    1. Technical requirements
    2. Amazon Web Services
      1. Amazon ECS – EC2-backed
      2. Amazon ECS – AWS Fargate backed
      3. Summing up AWS
    3. Microsoft Azure
      1. Azure web app for containers
      2. Azure container instances
      3. Summing up Microsoft Azure
    4. Google Cloud
      1. Google Cloud Run
      2. Summing up Google Cloud
    5. Summary
    6. Questions
    7. Further reading
  20. Chapter 11: Docker and Kubernetes
    1. Technical requirements
    2. An introduction to Kubernetes
      1. A brief history of containers at Google
      2. An overview of Kubernetes
      3. How does Docker fit in with Kubernetes?
    3. Using Kubernetes and Docker Desktop
    4. Kubernetes and other Docker tools
    5. Summary
    6. Questions
    7. Further reading
  21. Chapter 12: Discovering other Kubernetes options
    1. Technical requirements
    2. Deploying Kubernetes using Minikube
      1. Installing Minikube
      2. Interacting with your Kubernetes cluster node
      3. Managing Minikube
      4. Minikube summary
    3. Deploying Kubernetes using kind
      1. Installing Kind
      2. Launching a Kind cluster
      3. Interacting with your Kubernetes cluster node
      4. Kind summary
    4. Deploying Kubernetes using MicroK8s
      1. Installing MicroK8s
      2. Interacting with your Kubernetes cluster node
      3. MicroK8s summary
    5. Deploying Kubernetes using K3s
      1. Installing K3s
      2. Interacting with your Kubernetes cluster nodes
      3. One more thing – K3d
      4. K3s summary
    6. Summary
    7. Questions
    8. Further reading
  22. Chapter 13: Running Kubernetes in Public Clouds
    1. Technical requirements
    2. Microsoft Azure Kubernetes Service (AKS)
      1. Launching a cluster using the web portal
      2. Launching a cluster using the command-line tools
      3. Launching an application
      4. Cluster information
      5. Microsoft Azure Kubernetes Service summary
    3. Google Kubernetes Engine (GKE)
      1. Launching a cluster using the web portal
      2. Launching a cluster using the command-line tools
      3. Launching an application
      4. Cluster information
      5. Google Kubernetes Engine summary
    4. Amazon Elastic Kubernetes Service (EKS)
      1. Launching a cluster using the command-line tools
      2. Launching an application
      3. Cluster information
      4. Amazon Elastic Kubernetes Service summary
    5. DigitalOcean Kubernetes
    6. Summary
    7. Questions
    8. Further reading
  23. Section 3: Best Practices
  24. Chapter 14: Docker Security
    1. Technical requirements
    2. Container considerations
      1. The advantages
      2. Your Docker hosts
      3. Image trust
    3. Docker commands
      1. The Docker Run command
      2. The docker diff command
    4. Best practices
      1. Docker best practices
      2. The Center for Internet Security benchmark
    5. The Docker Bench Security application
    6. Third-party security services
      1. Quay
      2. Clair
      3. Anchore
    7. Summary
    8. Questions
    9. Further reading
  25. Chapter 15: Docker Workflows
    1. Technical requirements
    2. Docker for development
      1. Docker and Azure DevOps
    3. Monitoring Docker and Kubernetes
    4. What does production look like?
      1. Your Docker hosts
      2. Clustering
      3. Image registries
    5. Summary
    6. Questions
    7. Further reading
  26. Chapter 16: Next Steps with Docker
    1. The Moby Project
    2. Contributing to Docker
      1. Contributing to the code
      2. Offering Docker support
      3. Other contributions
    3. The Cloud Native Computing Foundation
      1. Graduated projects
      2. Incubating projects
      3. The CNCF landscape
    4. Summary
  27. Assessments
    1. Chapter 1, Docker Overview
    2. Chapter 2, Building Container Images
    3. Chapter 3, Storing and Distributing Images
    4. Chapter 4, Managing Containers
    5. Chapter 5, Docker Compose
    6. Chapter 6, Docker Machine, Vagrant, and Multipass
    7. Chapter 7, Moving from Linux to Windows Containers
    8. Chapter 8, Clustering with Docker Swarm
    9. Chapter 9, Portainer – a GUI for Docker
    10. Chapter 10, Running Docker in Public Clouds
    11. Chapter 11, Docker and Kubernetes
    12. Chapter 12, Discovering other Kubernetes options
    13. Chapter 13, Running Kubernetes in Public Clouds
    14. Chapter 14, Docker Security
    15. Chapter 15, Docker Workflows
  28. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering Docker - Fourth Edition
  • Author(s): Russ McKendrick
  • Release date: October 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781839216572