Table of contents
No headings in the article.
By using Docker Compose, you simplify container orchestration, especially when managing multi-container setups. Follow these steps for a quick start:
Download and Install Docker desktop on your machine.
Create a
docker compose.yaml
file:
Define your services, networks, and volumes in one place. This YAML file makes it easier to manage multi-container Docker applications. In this guide, we will clone a sample application named todo-list-app. The app contains a docker compose.yaml file.
Open a terminal
clone the sample application
- run the command
git clone
https://github.com/dockersamples/todo-list-app
- run the command
The app contains a docker compose.yaml file which defines:
An app service that builds from a node:18-alpine image.
A database service that pulls a mysql image.
volume for persistent data
- Build and run containers:
Ensure Docker desktop is open and running
Move to the todo-list-app directory
cd todo-list-app
Use Docker Compose to build and start your containers with a single command: the -d flag will enable detached mode.
docker compose up -d --build
This will automatically build and launch all services defined in docker compose.yaml
.
Test Your App:
You can view and manage containers in the terminal using command or on the Docker desktop. Let us use docker desktop to view our app:
Click on the container blade on the left pane of docker desktop
- Expand the todo-list-app and verify the containers and running.
- Open the port to view the app in a browser
- Type list item and click add item
Stopping and removing containers:
To stop and clean up, use:
docker compose down