DEV Community

Gitau Waiganjo
Gitau Waiganjo

Posted on

Introduction to Docker Compose

What is Docker Compose?
Docker Compose is a tool that helps you run and manage multi-container Docker applications with a single configuration file.
Without Compose → You run each container manually using docker run.
With Compose → You describe everything (services, networks, volumes) in one YAML file, then start everything with one command:
bash
docker-compose up
Think of it as a project manager for containers.
Why Use Docker Compose?

  • Run multiple containers together (e.g., app + database).
  • One command starts/stops everything.
  • Easy to share setup (just send the docker-compose.yml file).
  • Works the same on your machine, server, or cloud.
    Example use cases:

  • A web app (React frontend + Node.js backend + PostgreSQL database).

  • A data pipeline (Kafka + Spark + Grafana).

  • A local development environment (Nginx + PHP + MySQL).

Key Concepts

  1. services → Containers (like web, redis).
  2. image → Which Docker image to use.
  3. ports → Maps host port → container port (5000:5000).
  4. volumes → Persist data or share code.
  5. depends_on → Start order (e.g., web depends on redis).

Top comments (0)