Learn Docker - Fundamentals of Docker 18.x

Book description

Enhance your software deployment workflow using containers

About This Book
  • Get up-and-running with basic to advanced concepts of Docker
  • Get acquainted with concepts such as Docker containers, Docker images, orchestrators and so on.
  • Practical test-based approach to learning a prominent containerization tool
Who This Book Is For

This book is targeted at system administrators, operations engineers, DevOps engineers, and developers or stakeholders who are interested in getting started with Docker from scratch. No prior experience with Docker Containers is required.

What You Will Learn
  • Containerize your traditional or microservice-based application
  • Share or ship your application as an immutable container image
  • Build a Docker swarm and a Kubernetes cluster in the cloud
  • Run a highly distributed application using Docker Swarm or Kubernetes
  • Update or rollback a distributed application with zero downtime
  • Secure your applications via encapsulation, networks, and secrets
  • Know your options when deploying your containerized app into the cloud
In Detail

Docker containers have revolutionized the software supply chain in small and big enterprises. Never before has a new technology so rapidly penetrated the top 500 enterprises worldwide. Companies that embrace containers and containerize their traditional mission-critical applications have reported savings of at least 50% in total maintenance cost and a reduction of 90% (or more) of the time required to deploy new versions of those applications. Furthermore they are benefitting from increased security just by using containers as opposed to running applications outside containers.

This book starts from scratch, introducing you to Docker fundamentals and setting up an environment to work with it. Then we delve into concepts such as Docker containers, Docker images, Docker Compose, and so on. We will also cover the concepts of deployment, orchestration, networking, and security. Furthermore, we explain Docker functionalities on public clouds such as AWS.

By the end of this book, you will have hands-on experience working with Docker containers and orchestrators such as SwarmKit and Kubernetes.

Style and approach

The simple end-to-end guide will help you learn everything about how to containerize, ship, and run both a traditional application and a modern microservice-based application on-premise or in the cloud.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Learn Docker – Fundamentals of Docker 18.x
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. 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. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. 1. What Are Containers and Why Should I Use Them?
    1. Technical requirements
    2. What are containers?
    3. Why are containers important?
    4. What's the benefit for me or for my company?
    5. The Moby project
    6. Docker products
      1. Docker CE
      2. Docker EE
    7. The container ecosystem
    8. Container architecture
    9. Summary
    10. Questions
    11. Further reading
  7. 2. Setting up a Working Environment
    1. Technical requirements
    2. The Linux command shell
    3. PowerShell for Windows
    4. Using a package manager
      1. Installing Homebrew on a Mac
      2. Installing Chocolatey on Windows
    5. Choosing a code editor
    6. Docker Toolbox
    7. Docker for Mac and Docker for Windows
      1. Installing Docker for Mac
      2. Installing Docker for Windows
      3. Using docker-machine on Windows with Hyper-V
    8. Minikube
      1. Installing Minikube on  Mac and Windows
      2. Testing Minikube and kubectl
    9. Summary
    10. Questions
    11. Further reading
  8. 3. Working with Containers
    1. Technical requirements
    2. Running the first container
    3. Starting, stopping, and removing containers
      1. Running a random quotes container
      2. Listing containers
      3. Stopping and starting containers
      4. Removing containers
    4. Inspecting containers
    5. Exec into a running container
    6. Attaching to a running container
    7. Retrieving container logs
      1. Logging drivers
      2. Using a container-specific logging driver
      3. Advanced topic – changing the default logging driver
    8. Anatomy of containers
      1. Architecture
      2. Namespaces
      3. Control groups (cgroups)
      4. Union filesystem (UnionFS)
      5. Container plumbing
        1. Runc
        2. Containerd
    9. Summary
    10. Questions
    11. Further reading
  9. 4. Creating and Managing Container Images
    1. What are images?
      1. The layered filesystem
      2. The writable container layer
      3. Copy-on-write
      4. Graph drivers
    2. Creating images
      1. Interactive image creation
      2. Using Dockerfiles
        1. The FROM keyword
        2. The RUN keyword
        3. The COPY and ADD keywords
        4. The WORKDIR keyword
        5. The CMD and ENTRYPOINT keywords
        6. A complex Dockerfile
        7. Building an image
        8. Multistep builds
        9. Dockerfile best practices
      3. Saving and loading images
    3. Sharing or shipping images
      1. Tagging an image
      2. Image namespaces
      3. Official images
      4. Pushing images to a registry
    4. Summary
    5. Questions
    6. Further reading
  10. 5. Data Volumes and System Management
    1. Technical requirements
    2. Creating and mounting data volumes
      1. Modifying the container layer
      2. Creating volumes
      3. Mounting a volume
      4. Removing volumes
    3. Sharing data between containers
    4. Using host volumes
    5. Defining volumes in images
    6. Obtaining Docker system information
    7. Listing resource consumption
    8. Pruning unused resources
      1. Pruning containers
      2. Pruning images
      3. Pruning volumes
      4. Pruning networks
      5. Pruning everything
    9. Consuming Docker system events
    10. Summary
    11. Questions
    12. Further reading
  11. 6. Distributed Application Architecture
    1. What is a distributed application architecture?
      1. Defining the terminology
    2. Patterns and best practices
      1. Loosely coupled components
      2. Stateful versus stateless
      3. Service discovery
      4. Routing
      5. Load balancing
      6. Defensive programming
        1. Retries
        2. Logging
        3. Error handling
      7. Redundancy
      8. Health checks
      9. Circuit breaker pattern
    3. Running in production
      1. Logging
      2. Tracing
      3. Monitoring
      4. Application updates
        1. Rolling updates
        2. Blue-green deployments
        3. Canary releases
        4. Irreversible data changes
        5. Rollback
    4. Summary
    5. Questions
    6. Further reading
  12. 7. Single-Host Networking
    1. Technical requirements
    2. The container network model
    3. Network firewalling
    4. The bridge network
    5. The host network
    6. The null network
    7. Running in an existing network namespace
    8. Port management
    9. Summary
    10. Questions
    11. Further reading
  13. 8. Docker Compose
    1. Technical requirements
    2. Demystifying declarative versus imperative
    3. Running a multi-service app
    4. Scaling a service
    5. Building and pushing an application
    6. Summary
    7. Questions
    8. Further reading
  14. 9. Orchestrators
    1. What are orchestrators and why do we need them?
    2. The tasks of an orchestrator
      1. Reconciling the desired state
      2. Replicated and global services
      3. Service discovery
      4. Routing
      5. Load balancing
      6. Scaling
      7. Self-healing
      8. Zero downtime deployments
      9. Affinity and location awareness
      10. Security
        1. Secure communication and cryptographic node identity
        2. Secure networks and network policies
        3. Role-based access control (RBAC)
        4. Secrets
        5. Content trust
        6. Reverse uptime
      11. Introspection
    3. Overview of popular orchestrators
      1. Kubernetes
      2. Docker Swarm
      3. Apache Mesos and Marathon
      4. Amazon ECS
      5. Microsoft ACS 
    4. Summary
    5. Questions
    6. Further reading
  15. 10. Introduction to Docker Swarm
    1. Architecture
    2. Swarm nodes
      1. Swarm managers
      2. Swarm workers  
    3. Stacks, services, and tasks
      1. Services
      2. Task
      3. Stack
    4. Multi-host networking
    5. Creating a Docker Swarm
      1. Creating a local single node swarm
      2. Creating a local swarm in VirtualBox or Hyper-V
      3. Using Play with Docker (PWD) to generate a Swarm
      4. Creating a Docker Swarm in the cloud
    6. Deploying a first application
      1. Creating a service
      2. Inspecting the service and its tasks
      3. Logs of a service
      4. Reconciling the desired state
      5. Deleting a service or a stack
      6. Deploying a multi-service stack
    7. The swarm routing mesh
    8. Summary
    9. Questions
    10. Further reading
  16. 11. Zero Downtime Deployments and Secrets
    1. Technical requirements
    2. Zero downtime deployment
      1. Popular deployment strategies
      2. Rolling updates
      3. Health checks
      4. Rollback
      5. Blue–green deployments
      6. Canary releases
    3. Secrets
      1. Creating secrets
      2. Using a secret
      3. Simulating secrets in a development environment
      4. Secrets and legacy applications
      5. Updating secrets
    4. Summary
    5. Questions
    6. Further reading
  17. 12. Introduction to Kubernetes
    1. Technical requirements
    2. Architecture
    3. Kubernetes master nodes
    4. Cluster nodes
    5. Introduction to Minikube
    6. Kubernetes support in Docker for Desktop
    7. Pods
      1. Comparing Docker container and Kubernetes pod networking
      2. Sharing the network namespace
      3. Pod life cycle
      4. Pod specification
      5. Pods and volumes
    8. Kubernetes ReplicaSet
      1. ReplicaSet specification
      2. Self-healing
    9. Kubernetes deployment
    10. Kubernetes service
    11. Context-based routing
    12. Comparing SwarmKit with Kubernetes
    13. Summary
    14. Questions
    15. Further reading
  18. 13. Deploying, Updating, and Securing an Application with Kubernetes
    1. Technical requirements
    2. Deploying a first application
      1. Deploying the web component
      2. Deploying the database
      3. Streamlining the deployment
    3. Zero downtime deployments
      1. Rolling updates
      2. Blue–green deployment
    4. Kubernetes secrets
      1. Manually defining secrets
      2. Creating secrets with kubectl
      3. Using secrets in a pod
      4. Secret values in environment variables
    5. Summary
    6. Questions
    7. Further reading
  19. 14. Running a Containerized App in the Cloud
    1. Technical requirements
    2. Deploying our application into AWS ECS
      1. Introduction to ECS
      2. Creating a Fargate ECS cluster of AWS
      3. Authoring a task definition
      4. Running a task in ECS
      5. Modifying the task definition
      6. Adding the database component to the application
    3. Deploying and using Docker EE on AWS
      1. Provisioning the infrastructure
      2. Installing Docker
      3. Installing Docker UCP
      4. Remote admin the UCP cluster
      5. Deploying to Docker Swarm
      6. Deploying to Kubernetes
    4. A short peek into Azure’s container offerings
    5. A short peek into Google’s container offerings
    6. Summary
    7. Questions
    8. Further reading
  20. Assessment
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Chapter 12
    13. Chapter 13
    14. Chapter 14
  21. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Learn Docker - Fundamentals of Docker 18.x
  • Author(s): Gabriel N. Schenker
  • Release date: April 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788997027