I Help You
Cloud & DevOps

Docker Compose

Docker Compose is a tool for defining and running applications made of several Docker containers. The services, networks and volumes are described in one YAML file (compose.yaml or docker-compose.yml), and docker compose up starts them all together.

A typical file runs a web app, a database and a cache side by side, with environment variables, port mappings and persistent volumes. Containers in the same Compose project reach each other by service name, such as db:5432. Compose is mostly used for local development and testing; Kubernetes is used to run containers across many servers in production.

ExampleYAML
services:
  web:
    build: .
    ports:
      - "3000:3000"
    depends_on:
      - db
  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: example
    volumes:
      - db-data:/var/lib/postgresql/data
volumes:
  db-data: