An Intro to Docker Compose
What is Docker Compose?
Docker Compose is a tool that allows you to configure, build and run multiple containers. It's incredibly useful for building and deploying apps that use multiple services, each with their own container.
For example, let's say you have an app that uses 3 services:
- site
: An ecommerce site that lets users browse and shop for items.
- database
: A database that stores user, product, and order information.
- notifier
: A script that monitors your database and sends email notifications to users when their orders have shipped.
Your app directory structure would look like this:
app
├── database
│ └── Dockerfile
│ └── ...
├── notifier
│ └── Dockerfile
│ └── ...
└── site
└── Dockerfile
└── ...
Normally, you'd have to start 3 containers yourself, either by running docker run
for each image or by writing a custom script to launch them all. But with Docker Compose, you can launch all 3 containers with a single file AND configure them to