Simplify Container Orchestration with Docker Compose

Simplify Container Orchestration with Docker Compose

Table of contents

No heading

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:

  1. Download and Install Docker desktop on your machine.

  2. 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.

Image description

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

  1. 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
    

Image description

This will automatically build and launch all services defined in docker compose.yaml.

  1. 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.

Image description

  • Open the port to view the app in a browser

Image description

  • Type list item and click add item

Image description

  1. Stopping and removing containers:

    To stop and clean up, use:

     docker compose down