Back to Blog
team@tinypod.app

Docker Compose Explained: Multi-Container Applications Made Easy

Most real-world apps need multiple containers. Docker Compose lets you define and run them together. Here's how it works.

dockerdocker-composecontainers

Beyond Single Containers


A real-world application rarely runs as a single container. A typical web app needs:

  • The application itself (Node.js, Python, etc.)
  • A database (PostgreSQL, MySQL)
  • A cache (Redis)
  • Maybe a background worker
  • Maybe a reverse proxy

  • Docker Compose lets you define all of these in a single YAML file and manage them as a unit.


    The docker-compose.yml File


    A Compose file defines services, networks, and volumes. Here's a simplified example for a web app with a database:


    services:

    web:

    image: myapp:latest

    ports:

  • "3000:3000"
  • environment:

  • DATABASE_URL=postgresql://postgres:secret@db:5432/myapp
  • depends_on:

  • db
  • db:

    image: postgres:16

    environment:

  • POSTGRES_PASSWORD=secret
  • POSTGRES_DB=myapp
  • volumes:

  • pgdata:/var/lib/postgresql/data

  • volumes:

    pgdata:


    Key Concepts


    Services

    Each service is a container. The name (web, db) becomes the hostname on the internal network, so the web container can reach the database at db:5432.


    Networks

    Compose creates a default network for all services. Containers can communicate by service name. No need to expose database ports to the internet.


    Volumes

    Named volumes persist data across container restarts. Without a volume, your database data disappears when the container restarts.


    Dependencies

    depends_on controls startup order. The web service waits for db to start before launching.


    Common Commands


  • docker compose up -d — Start all services in background
  • docker compose down — Stop and remove all services
  • docker compose logs -f — Follow logs from all services
  • docker compose ps — List running services
  • docker compose pull — Pull latest images

  • TinyPod Templates


    TinyPod's template system is essentially Docker Compose for the cloud. When you deploy a template like "Grafana + Prometheus," we create all the services, wire up the networking, and configure persistent storage — the same thing docker-compose.yml does, but without managing a server.


    Browse 130+ pre-configured templates in our directory and deploy them with one click.