🚀 Learn to Start and Stop All Microservices with Docker Compose
SOVANNARO

SOVANNARO @sovannaro

About: Passionate developer specializing in JavaScript, TypeScript, React, Vue, and Angular. I thrive on solving problems and building innovative solutions that make a difference in the modern world.

Location:
Phnom Penh, Cambodia
Joined:
Dec 1, 2021

🚀 Learn to Start and Stop All Microservices with Docker Compose

Publish Date: Jul 26 '25
0 0

In this lecture, you'll learn how to use Docker Compose to easily start and stop multiple microservices using just a few simple commands.


🧩 Why Use Docker Compose?

Docker Compose helps you run multiple containers (like microservices) at once using a single command, rather than running them one-by-one with separate docker run commands.


🛠 The docker-compose.yml File

Docker Compose needs a special file named docker-compose.yml where you define all your services (containers). Without this file, the docker compose up command won't work.

📌 Important: Run docker compose up from the folder where the docker-compose.yml file is located.


▶️ Starting All Microservices

To start all the containers (microservices), run:

docker compose up -d
Enter fullscreen mode Exit fullscreen mode
  • -d means "detached mode" (runs in the background so your terminal stays free).
  • Example: If you're in the correct folder and run this command, it will start all services defined in the docker-compose.yml.

Then you can check that everything is running with:

docker ps
Enter fullscreen mode Exit fullscreen mode

It will list all the running containers.


✅ Confirm Services Are Working

You can now test each microservice (like Accounts, Loans, Cards) using tools like Postman to send API requests. If you get a successful response, your services are working fine!


⛔️ Stopping All Microservices

To stop and remove all running containers, use:

docker compose down
Enter fullscreen mode Exit fullscreen mode

This command stops and deletes all the containers created by Docker Compose.

📝 If you just want to stop them but not delete, use:

docker compose stop
Enter fullscreen mode Exit fullscreen mode

However, it’s usually better to use down so everything is cleaned up.


🔁 Recap of Key Commands

Command What It Does
docker compose up -d Starts all containers in background
docker ps Shows running containers
docker compose down Stops and removes containers
docker compose stop Only stops containers (doesn’t remove)

⚠️ YAML File Tips

  • Indentation in docker-compose.yml is very important.
  • Be careful with spaces — YAML files break easily if formatting is wrong.
  • You can find the sample file in the GitHub repo.

💡 Summary

With Docker Compose, you can:

  • Start all microservices with one command ✅
  • Stop and delete them easily ✅
  • Save time compared to running containers one by one ✅

This makes it super efficient to manage your microservices during development.

Comments 0 total

    Add comment