A Developer's Essential Guide to Docker Compose: Simplify the development and orchestration of multi-container applications

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Start defining your infrastructure using Docker Compose and leverage it for everyday development or deployment

Key Features

  • Distribute your code in an easier way for developers to get started
  • Set up complex infrastructure for development and CI/CD purposes
  • Deploy simple multi-container applications using Docker Compose

Book Description

Software development is becoming increasingly complex due to the various software components used. Applications need to be packaged with software components to facilitate their operations, making it complicated to run them. With Docker Compose, a single command can set up your application and the needed dependencies.

This book starts with an overview of Docker Compose and its usage and then shows how to create an application. You will also get to grips with the fundamentals of Docker volumes and network, along with Compose commands, their purpose, and use cases. Next, you will set up databases for daily usage using Compose and, leveraging Docker networking, you will establish communication between microservices. You will also run entire stacks locally on Compose, simulate production environments, and enhance CI/CD jobs using Docker Compose. Later chapters will show you how to benefit from Docker Compose for production deployments, provision infrastructure on public clouds such as AWS and Azure, and wrap up with Compose deployments on said infrastructure.

By the end of this book, you will have learned how to effectively utilize Docker Compose for day-to-day development.

What you will learn

  • Create multi-container applications using Docker Compose
  • Use Docker Compose for daily development
  • Connect microservices leveraging Docker network fundamentals
  • Add monitoring to services leveraging Prometheus
  • Deploy to production using Docker Compose
  • Translate Compose files to Kubernetes deployments

Who this book is for

This book is for software engineers, developer advocates, and DevOps engineers looking to set up multi-container Docker applications using Compose without the need to set up a Docker orchestration engine. It is also for team leads looking to increase the productivity of an organization's software teams by streamlining the provisioning of complex development environments locally using Docker Compose. Readers are expected to understand containerization and must possess fundamental Docker knowledge to get started with this book.

Table of Contents

  1. Introduction to Docker Compose
  2. Running the First Application Using Compose
  3. Network and Volumes Fundamentals
  4. Executing Docker Compose Commands
  5. Connecting Microservices
  6. Monitoring Services with Prometheus
  7. Combining Compose Files
  8. Simulating Production Locally
  9. Creating Advanced CI/CD Tasks
  10. Deploying Docker Compose Using Remote Hosts
  11. Deploying Docker Compose to AWS
  12. Deploying Docker Compose to Azure
  13. Migrating to Kubernetes Configuration Using Compose

Author(s): Emmanouil Gkatziouras
Edition: 1
Publisher: Packt Publishing
Year: 2022

Language: English
Commentary: Publisher PDF
Pages: 264
City: Birmingham, UK
Tags: Docker; Docker Compose; Orchestration; Containers; Container Orchestrator; Distributed Systems; CI/CD; Cloud

Cover
Title Page
Copyright
Contributors
Table of Contents
Preface
Part 1: Docker Compose 101
Chapter 1: Introduction to Docker Compose
Technical requirements
Introducing Docker Compose and its usage
Installing Docker Compose
Docker Desktop
Installing Docker
docker compose versus docker-compose
Understanding how Docker Compose works
Your first Docker Compose file
Using your Docker image on Docker Compose
Summary
Chapter 2: Running the First Application Using Compose
Technical requirements
Creating a core application
Installing Go
A REST API in Go using Gin
The application
Running Redis using Compose
Shelling into a container managed by Compose
Interacting with a Docker Compose service
Packaging your application with Docker and Compose
Enabling environment configuration
Docker image creation
Running the image
Build an image using Compose
Running your multi-container application using Compose
Health check
Depending on services
Labels
Images
Containers
Summary
Chapter 3: Network and Volumes Fundamentals
Technical requirements
Explaining Docker volumes
Attaching a Docker volume to a container
Shared volumes
Read-only volumes
Docker volume drivers
Using a volume driver versus mounting locally
Declaring Docker volumes on Compose files
Attaching Docker volumes to an existing application
Creating a configuration file
Mounting a file using volume
Mounting read-only volumes
Docker networking
Bridge
Host
Overlay
Defining networks on a Compose configuration
Adding an extra network to the current application
Summary
Chapter 4: Executing Docker Compose Commands
Technical requirements
Introducing Compose commands
The Docker CLI versus Compose commands
Setting up the target application
Provisioning commands
build
create
up
Container commands
exec
run
pause
unpause
start and stop
restart
kill
ps
Cleanup commands
down
rm
Image commands
List images
Pulling images
Pushing images
Local Docker registry on Compose
Pushing to the local registry
Monitoring commands
Logs
top
Events
Other commands
help
version
port
config
Summary
Part 2: Daily Development with Docker Compose
Chapter 5: Connecting Microservices
Technical requirements
Introducing the location microservice
Adding a location service to Compose
Adding a network for the location microservice
Executing requests to the location microservice
Streaming task events
Adding a task events processing microservice
Summary
Chapter 6: Monitoring Services with Prometheus
What is Prometheus?
Adding an endpoint for Prometheus
Adding the metrics endpoint to the Task Manager
Adding the metrics endpoint to the location service
Exporting metrics from the Event Service
Configuring Prometheus to parse metrics
Adding Prometheus to the Compose network
Pushing metrics to Prometheus
Creating your first metrics query
Adding an alert
Summary
Chapter 7: Combining Compose Files
Technical requirements
Splitting Compose files
Task Manager base
Location service
Event service
Task Manager
Prometheus
Combining Compose files
Selecting the Compose files to run
Using Hoverfly
Extending services
Capturing traffic with Hoverfly
Creating mock applications using Ηoverfly
Creating different environments
Running with capturing enabled
Running with monitoring disabled
Running applications individually
Combining multiple Compose files into one
Using config
Summary
Chapter 8: Simulating Production Locally
Technical requirements
Segregating private and public workloads
Setting up DynamoDB locally
Creating DynamoDB tables
Interacting with the Local DynamoDB
Setting up SQS locally
Setting up S3 locally
Setting up a REST-based Lambda function
Setting up an SQS-based Lambda function
Docker Compose links
Connecting the Lambda functions
Summary
Chapter 9: Creating Advanced CI/CD Tasks
Technical requirements
Introduction to CI/CD
Using Docker Compose with GitHub Actions
Creating your first GitHub Action
Caching built images
Building application images
Testing your Compose application
Using Docker Compose with Bitbucket pipelines
Creating your first Bitbucket pipeline
Caching Compose and Docker images
Building application images
Testing your Compose application
Using Docker Compose with Travis
Creating your first Travis job
Caching Compose
Building application images
Testing your Compose application
Summary
Part 3: Deployment with Docker Compose
Chapter 10: Deploying Docker Compose Using Remote Hosts
Technical requirements
Docker remote hosts
Creating a remote Docker host
Creating a Docker host on AWS EC2
Using the remote Docker host
Docker Contexts
Deploying Compose to remote hosts
Executing remote host deployments through your IDE
Summary
Chapter 11: Deploying Docker Compose to AWS
Technical requirements
Introduction to AWS ECS
Hosting your Docker images on AWS ECR
Provision ECR using AWS CLI
Provision ECR using Terraform
Storing a Terraform state file
Pushing images to ECR
Adapting the Compose application images
Deploying your application to an ECS cluster
Running your Compose application to an existing cluster
Creating a log group
Creating a private network
Security groups
Configuring the ECS cluster and the load balancer
Updating the Compose file
Running your Compose application on existing infrastructure
Advanced Docker Compose concepts on ECS
Updating the application
Scaling the application
Using secrets
Summary
Chapter 12: Deploying Docker Compose to Azure
Technical requirements
An introduction to ACI
Pushing to an Azure container registry
Storing the Terraform state file
Deploying on ACI
Summary
Chapter 13: Migrating to Kubernetes Configuration Using Compose
Technical requirements
Introduction to Kubernetes
Kubernetes components and Compose
Compose applications versus namespaces
Compose services versus Kubernetes services
Labels
Compose networks versus network policies
Using Kompose to convert files
Introduction to Minikube
Deploying to Kubernetes
Summary
Index
About Packt
Other Books You May Enjoy