Docs / Containers & Docker / Docker Compose: Getting Started

Docker Compose: Getting Started

By Admin · Feb 25, 2026 · Updated Apr 25, 2026 · 393 views · 1 min read

Docker Compose defines and runs multi-container applications using a YAML file.

Create docker-compose.yml

version: "3.8"
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/share/nginx/html

  db:
    image: mysql:8
    environment:
      MYSQL_ROOT_PASSWORD: secretpassword
      MYSQL_DATABASE: myapp
    volumes:
      - db_data:/var/lib/mysql

volumes:
  db_data:

Commands

# Start services
docker compose up -d

# Stop services
docker compose down

# View logs
docker compose logs -f

# Rebuild
docker compose up -d --build

# List containers
docker compose ps

Was this article helpful?